2024-01-30 15:18:58 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
2024-11-07 14:32:10 +00:00
|
|
|
rawclient "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
2024-01-30 15:18:58 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var shardsDetachCmd = &cobra.Command{
|
|
|
|
Use: "detach",
|
|
|
|
Short: "Detach and close the shards",
|
|
|
|
Long: "Detach and close the shards",
|
|
|
|
Run: shardsDetach,
|
|
|
|
}
|
|
|
|
|
|
|
|
func shardsDetach(cmd *cobra.Command, _ []string) {
|
|
|
|
pk := key.Get(cmd)
|
|
|
|
|
|
|
|
req := &control.DetachShardsRequest{
|
|
|
|
Body: &control.DetachShardsRequest_Body{
|
|
|
|
Shard_ID: getShardIDListFromIDFlag(cmd, false),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
signRequest(cmd, pk, req)
|
|
|
|
|
|
|
|
cli := getClient(cmd, pk)
|
|
|
|
|
|
|
|
var resp *control.DetachShardsResponse
|
|
|
|
var err error
|
|
|
|
err = cli.ExecRaw(func(client *rawclient.Client) error {
|
|
|
|
resp, err = control.DetachShards(client, req)
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
|
|
|
|
|
|
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
|
|
|
|
|
|
|
cmd.Println("Shard mode update request successfully sent.")
|
|
|
|
}
|
|
|
|
|
|
|
|
func initControlShardsDetachCmd() {
|
|
|
|
initControlFlags(shardsDetachCmd)
|
|
|
|
|
|
|
|
flags := shardsDetachCmd.Flags()
|
|
|
|
flags.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
|
|
|
}
|