forked from TrueCloudLab/frostfs-node
Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
42554a9298
commit
923f84722a
934 changed files with 3470 additions and 3451 deletions
34
cmd/frostfs-cli/modules/netmap/get_epoch.go
Normal file
34
cmd/frostfs-cli/modules/netmap/get_epoch.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var getEpochCmd = &cobra.Command{
|
||||
Use: "epoch",
|
||||
Short: "Get current epoch number",
|
||||
Long: "Get current epoch number",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
p := key.GetOrGenerate(cmd)
|
||||
cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC)
|
||||
|
||||
var prm internalclient.NetworkInfoPrm
|
||||
prm.SetClient(cli)
|
||||
|
||||
res, err := internalclient.NetworkInfo(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
||||
netInfo := res.NetworkInfo()
|
||||
|
||||
cmd.Println(netInfo.CurrentEpoch())
|
||||
},
|
||||
}
|
||||
|
||||
func initGetEpochCmd() {
|
||||
commonflags.Init(getEpochCmd)
|
||||
commonflags.InitAPI(getEpochCmd)
|
||||
}
|
63
cmd/frostfs-cli/modules/netmap/netinfo.go
Normal file
63
cmd/frostfs-cli/modules/netmap/netinfo.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"time"
|
||||
|
||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var netInfoCmd = &cobra.Command{
|
||||
Use: "netinfo",
|
||||
Short: "Get information about NeoFS network",
|
||||
Long: "Get information about NeoFS network",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
p := key.GetOrGenerate(cmd)
|
||||
cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC)
|
||||
|
||||
var prm internalclient.NetworkInfoPrm
|
||||
prm.SetClient(cli)
|
||||
|
||||
res, err := internalclient.NetworkInfo(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
||||
netInfo := res.NetworkInfo()
|
||||
|
||||
cmd.Printf("Epoch: %d\n", netInfo.CurrentEpoch())
|
||||
|
||||
magic := netInfo.MagicNumber()
|
||||
cmd.Printf("Network magic: [%s] %d\n", netmode.Magic(magic), magic)
|
||||
|
||||
cmd.Printf("Time per block: %s\n", time.Duration(netInfo.MsPerBlock())*time.Millisecond)
|
||||
|
||||
const format = " %s: %v\n"
|
||||
|
||||
cmd.Println("NeoFS network configuration (system)")
|
||||
cmd.Printf(format, "Audit fee", netInfo.AuditFee())
|
||||
cmd.Printf(format, "Storage price", netInfo.StoragePrice())
|
||||
cmd.Printf(format, "Container fee", netInfo.ContainerFee())
|
||||
cmd.Printf(format, "EigenTrust alpha", netInfo.EigenTrustAlpha())
|
||||
cmd.Printf(format, "Number of EigenTrust iterations", netInfo.NumberOfEigenTrustIterations())
|
||||
cmd.Printf(format, "Epoch duration", netInfo.EpochDuration())
|
||||
cmd.Printf(format, "Inner Ring candidate fee", netInfo.IRCandidateFee())
|
||||
cmd.Printf(format, "Maximum object size", netInfo.MaxObjectSize())
|
||||
cmd.Printf(format, "Withdrawal fee", netInfo.WithdrawalFee())
|
||||
cmd.Printf(format, "Homomorphic hashing disabled", netInfo.HomomorphicHashingDisabled())
|
||||
cmd.Printf(format, "Maintenance mode allowed", netInfo.MaintenanceModeAllowed())
|
||||
|
||||
cmd.Println("NeoFS network configuration (other)")
|
||||
netInfo.IterateRawNetworkParameters(func(name string, value []byte) {
|
||||
cmd.Printf(format, name, hex.EncodeToString(value))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
func initNetInfoCmd() {
|
||||
commonflags.Init(netInfoCmd)
|
||||
commonflags.InitAPI(netInfoCmd)
|
||||
}
|
70
cmd/frostfs-cli/modules/netmap/nodeinfo.go
Normal file
70
cmd/frostfs-cli/modules/netmap/nodeinfo.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const nodeInfoJSONFlag = commonflags.JSON
|
||||
|
||||
var nodeInfoCmd = &cobra.Command{
|
||||
Use: "nodeinfo",
|
||||
Short: "Get target node info",
|
||||
Long: `Get target node info`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
p := key.GetOrGenerate(cmd)
|
||||
cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC)
|
||||
|
||||
var prm internalclient.NodeInfoPrm
|
||||
prm.SetClient(cli)
|
||||
|
||||
res, err := internalclient.NodeInfo(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
||||
prettyPrintNodeInfo(cmd, res.NodeInfo())
|
||||
},
|
||||
}
|
||||
|
||||
func initNodeInfoCmd() {
|
||||
commonflags.Init(nodeInfoCmd)
|
||||
commonflags.InitAPI(nodeInfoCmd)
|
||||
nodeInfoCmd.Flags().Bool(nodeInfoJSONFlag, false, "Print node info in JSON format")
|
||||
}
|
||||
|
||||
func prettyPrintNodeInfo(cmd *cobra.Command, i netmap.NodeInfo) {
|
||||
isJSON, _ := cmd.Flags().GetBool(nodeInfoJSONFlag)
|
||||
if isJSON {
|
||||
common.PrettyPrintJSON(cmd, i, "node info")
|
||||
return
|
||||
}
|
||||
|
||||
cmd.Println("key:", hex.EncodeToString(i.PublicKey()))
|
||||
|
||||
var stateWord string
|
||||
switch {
|
||||
default:
|
||||
stateWord = "<undefined>"
|
||||
case i.IsOnline():
|
||||
stateWord = "online"
|
||||
case i.IsOffline():
|
||||
stateWord = "offline"
|
||||
case i.IsMaintenance():
|
||||
stateWord = "maintenance"
|
||||
}
|
||||
|
||||
cmd.Println("state:", stateWord)
|
||||
|
||||
netmap.IterateNetworkEndpoints(i, func(s string) {
|
||||
cmd.Println("address:", s)
|
||||
})
|
||||
|
||||
i.IterateAttributes(func(key, value string) {
|
||||
cmd.Printf("attribute: %s=%s\n", key, value)
|
||||
})
|
||||
}
|
32
cmd/frostfs-cli/modules/netmap/root.go
Normal file
32
cmd/frostfs-cli/modules/netmap/root.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Cmd = &cobra.Command{
|
||||
Use: "netmap",
|
||||
Short: "Operations with Network Map",
|
||||
Long: `Operations with Network Map`,
|
||||
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() {
|
||||
Cmd.AddCommand(
|
||||
getEpochCmd,
|
||||
nodeInfoCmd,
|
||||
netInfoCmd,
|
||||
snapshotCmd,
|
||||
)
|
||||
|
||||
initGetEpochCmd()
|
||||
initNetInfoCmd()
|
||||
initNodeInfoCmd()
|
||||
initSnapshotCmd()
|
||||
}
|
32
cmd/frostfs-cli/modules/netmap/snapshot.go
Normal file
32
cmd/frostfs-cli/modules/netmap/snapshot.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var snapshotCmd = &cobra.Command{
|
||||
Use: "snapshot",
|
||||
Short: "Request current local snapshot of the network map",
|
||||
Long: `Request current local snapshot of the network map`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
p := key.GetOrGenerate(cmd)
|
||||
cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC)
|
||||
|
||||
var prm internalclient.NetMapSnapshotPrm
|
||||
prm.SetClient(cli)
|
||||
|
||||
res, err := internalclient.NetMapSnapshot(prm)
|
||||
common.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
||||
common.PrettyPrintNetMap(cmd, res.NetMap())
|
||||
},
|
||||
}
|
||||
|
||||
func initSnapshotCmd() {
|
||||
commonflags.Init(snapshotCmd)
|
||||
commonflags.InitAPI(snapshotCmd)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue