forked from TrueCloudLab/frostfs-node
Compare commits
1 commit
master
...
feature/no
Author | SHA1 | Date | |
---|---|---|---|
d6eb50822a |
3 changed files with 74 additions and 0 deletions
32
cmd/frostfs-cli/modules/node/root.go
Normal file
32
cmd/frostfs-cli/modules/node/root.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Cmd represents the container command.
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "node",
|
||||
Short: "Operations related to node state",
|
||||
Long: "Operations related to node state",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
// bind exactly that cmd's flags to
|
||||
// the viper before execution
|
||||
commonflags.Bind(cmd)
|
||||
commonflags.BindAPI(cmd)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
nodeChildCommand := []*cobra.Command{
|
||||
nodeServicesCmd,
|
||||
}
|
||||
Cmd.AddCommand(nodeChildCommand...)
|
||||
|
||||
initNodeServicesCmd()
|
||||
|
||||
for _, nodeCommand := range nodeChildCommand {
|
||||
commonflags.InitAPI(nodeCommand)
|
||||
}
|
||||
}
|
40
cmd/frostfs-cli/modules/node/services.go
Normal file
40
cmd/frostfs-cli/modules/node/services.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
var nodeServicesCmd = &cobra.Command{
|
||||
Use: "services",
|
||||
Short: "Show services state for node",
|
||||
Long: "Show services state for node.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var a network.Address
|
||||
err := a.FromString(viper.GetViper().GetString(commonflags.RPC))
|
||||
common.ExitOnErr(cmd, "unable to parse RPC endpoint", err)
|
||||
|
||||
cc, err := grpc.DialContext(context.Background(), a.URIAddr(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
common.ExitOnErr(cmd, "unable to create client connection", err)
|
||||
|
||||
treeClient := tree.NewTreeServiceClient(cc)
|
||||
resp, err := treeClient.Healthcheck(context.Background(), new(tree.HealthcheckRequest))
|
||||
status := "available"
|
||||
if err != nil || resp == nil {
|
||||
status = "N/A"
|
||||
}
|
||||
cmd.Printf("tree service status: %s\n", status)
|
||||
},
|
||||
}
|
||||
|
||||
func initNodeServicesCmd() {
|
||||
commonflags.Init(nodeServicesCmd)
|
||||
}
|
|
@ -12,6 +12,7 @@ import (
|
|||
containerCli "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/container"
|
||||
controlCli "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/control"
|
||||
netmapCli "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/netmap"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/node"
|
||||
objectCli "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
||||
sessionCli "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/session"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/tree"
|
||||
|
@ -86,6 +87,7 @@ func init() {
|
|||
rootCmd.AddCommand(containerCli.Cmd)
|
||||
rootCmd.AddCommand(tree.Cmd)
|
||||
rootCmd.AddCommand(gendoc.Command(rootCmd, gendoc.Options{}))
|
||||
rootCmd.AddCommand(node.Cmd)
|
||||
}
|
||||
|
||||
func entryPoint(cmd *cobra.Command, _ []string) {
|
||||
|
|
Loading…
Reference in a new issue