2022-06-02 12:07:30 +00:00
|
|
|
package storagegroup
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
|
|
objectCli "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object_manager/storagegroup"
|
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
2022-06-02 12:07:30 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var sgListCmd = &cobra.Command{
|
|
|
|
Use: "list",
|
2023-01-27 10:44:39 +00:00
|
|
|
Short: "List storage groups in FrostFS container",
|
|
|
|
Long: "List storage groups in FrostFS container",
|
2022-06-02 12:07:30 +00:00
|
|
|
Run: listSG,
|
|
|
|
}
|
|
|
|
|
|
|
|
func initSGListCmd() {
|
|
|
|
commonflags.Init(sgListCmd)
|
|
|
|
|
2022-10-18 11:43:04 +00:00
|
|
|
sgListCmd.Flags().String(commonflags.CIDFlag, "", commonflags.CIDFlagUsage)
|
|
|
|
_ = sgListCmd.MarkFlagRequired(commonflags.CIDFlag)
|
2022-06-02 12:07:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func listSG(cmd *cobra.Command, _ []string) {
|
|
|
|
var cnr cid.ID
|
|
|
|
readCID(cmd, &cnr)
|
|
|
|
|
|
|
|
pk := key.GetOrGenerate(cmd)
|
|
|
|
|
2022-10-20 09:40:33 +00:00
|
|
|
cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC)
|
|
|
|
|
2022-06-02 12:07:30 +00:00
|
|
|
var prm internalclient.SearchObjectsPrm
|
|
|
|
objectCli.Prepare(cmd, &prm)
|
2022-10-20 09:40:33 +00:00
|
|
|
prm.SetClient(cli)
|
2022-06-02 12:07:30 +00:00
|
|
|
prm.SetContainerID(cnr)
|
|
|
|
prm.SetFilters(storagegroup.SearchQuery())
|
|
|
|
|
|
|
|
res, err := internalclient.SearchObjects(prm)
|
2023-01-16 09:20:16 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
2022-06-02 12:07:30 +00:00
|
|
|
|
|
|
|
ids := res.IDList()
|
|
|
|
|
|
|
|
cmd.Printf("Found %d storage groups.\n", len(ids))
|
|
|
|
|
|
|
|
for i := range ids {
|
|
|
|
cmd.Println(ids[i].String())
|
|
|
|
}
|
|
|
|
}
|