-
Notifications
You must be signed in to change notification settings - Fork 5
/
system.go
49 lines (40 loc) · 975 Bytes
/
system.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"context"
"encoding/json"
"fmt"
t_pb "github.com/0xef53/kvmrun/api/services/tasks/v1"
empty "github.com/golang/protobuf/ptypes/empty"
cli "github.com/urfave/cli/v2"
grpc "google.golang.org/grpc"
)
var systemCommands = &cli.Command{
Name: "system",
Usage: "manage kvmrund daemon",
Hidden: true,
HideHelp: true,
Category: "System",
Subcommands: []*cli.Command{
cmdPrintTasks,
},
}
var cmdPrintTasks = &cli.Command{
Name: "tasks",
Usage: "print a list of background tasks",
HideHelp: true,
Action: func(c *cli.Context) error {
return executeGRPC(c, listBackgroundTasks)
},
}
func listBackgroundTasks(ctx context.Context, vmname string, c *cli.Context, conn *grpc.ClientConn) error {
resp, err := t_pb.NewTaskServiceClient(conn).List(ctx, new(empty.Empty))
if err != nil {
return err
}
b, err := json.MarshalIndent(resp, "", " ")
if err != nil {
return err
}
fmt.Printf("%s\n", b)
return nil
}