2024-02-01 14:41:44 +00:00
|
|
|
package netmap
|
2023-01-31 10:33:33 +00:00
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
2024-02-02 12:26:57 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
2024-01-31 14:26:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
2023-03-07 13:38:26 +00:00
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
2023-01-31 10:33:33 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
2023-10-24 10:06:30 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
2023-01-31 10:33:33 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
func listNetmapCandidatesNodes(cmd *cobra.Command, _ []string) {
|
2024-01-31 14:26:26 +00:00
|
|
|
c, err := util.GetN3Client(viper.GetViper())
|
2023-01-31 10:33:33 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "can't create N3 client: %w", err)
|
|
|
|
|
|
|
|
inv := invoker.New(c, nil)
|
2023-10-24 10:06:30 +00:00
|
|
|
r := management.NewReader(inv)
|
2023-01-31 10:33:33 +00:00
|
|
|
|
2023-10-24 10:06:30 +00:00
|
|
|
cs, err := r.GetContractByID(1)
|
2023-01-31 10:33:33 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "can't get NNS contract info: %w", err)
|
|
|
|
|
2024-02-02 12:26:57 +00:00
|
|
|
nmHash, err := util.NNSResolveHash(inv, cs.Hash, util.DomainOf(constants.NetmapContract))
|
2023-01-31 10:33:33 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "can't get netmap contract hash: %w", err)
|
|
|
|
|
|
|
|
res, err := inv.Call(nmHash, "netmapCandidates")
|
|
|
|
commonCmd.ExitOnErr(cmd, "can't fetch list of network config keys from the netmap contract", err)
|
|
|
|
nm, err := netmap.DecodeNetMap(res.Stack)
|
|
|
|
commonCmd.ExitOnErr(cmd, "unable to decode netmap: %w", err)
|
|
|
|
commonCmd.PrettyPrintNetMap(cmd, *nm, !viper.GetBool(commonflags.Verbose))
|
|
|
|
}
|