2022-05-23 16:26:27 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"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"
|
2022-05-23 16:26:27 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
const dropObjectsFlag = "objects"
|
|
|
|
|
|
|
|
var dropObjectsCmd = &cobra.Command{
|
|
|
|
Use: "drop-objects",
|
|
|
|
Short: "Drop objects from the node's local storage",
|
|
|
|
Long: "Drop objects from the node's local storage",
|
2024-03-11 14:11:49 +00:00
|
|
|
Run: func(cmd *cobra.Command, _ []string) {
|
2022-05-24 08:22:23 +00:00
|
|
|
pk := key.Get(cmd)
|
2022-05-23 16:26:27 +00:00
|
|
|
|
|
|
|
dropObjectsList, _ := cmd.Flags().GetStringSlice(dropObjectsFlag)
|
2022-05-31 17:00:41 +00:00
|
|
|
binAddrList := make([][]byte, len(dropObjectsList))
|
2022-05-23 16:26:27 +00:00
|
|
|
|
|
|
|
for i := range dropObjectsList {
|
2022-05-31 17:00:41 +00:00
|
|
|
binAddrList[i] = []byte(dropObjectsList[i])
|
2022-05-23 16:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
body := new(control.DropObjectsRequest_Body)
|
|
|
|
body.SetAddressList(binAddrList)
|
|
|
|
|
|
|
|
req := new(control.DropObjectsRequest)
|
|
|
|
req.SetBody(body)
|
|
|
|
|
|
|
|
signRequest(cmd, pk, req)
|
|
|
|
|
|
|
|
cli := getClient(cmd, pk)
|
|
|
|
|
|
|
|
var resp *control.DropObjectsResponse
|
|
|
|
var err error
|
|
|
|
err = cli.ExecRaw(func(client *rawclient.Client) error {
|
|
|
|
resp, err = control.DropObjects(client, req)
|
|
|
|
return err
|
|
|
|
})
|
2023-01-16 09:20:16 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "", err)
|
2022-05-23 16:26:27 +00:00
|
|
|
|
|
|
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
|
|
|
|
|
|
|
cmd.Println("Objects were successfully marked to be removed.")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func initControlDropObjectsCmd() {
|
2022-10-17 15:37:15 +00:00
|
|
|
initControlFlags(dropObjectsCmd)
|
2022-05-23 16:26:27 +00:00
|
|
|
|
|
|
|
flags := dropObjectsCmd.Flags()
|
|
|
|
flags.StringSliceP(dropObjectsFlag, "o", nil,
|
|
|
|
"List of object addresses to be removed in string format")
|
|
|
|
|
|
|
|
_ = dropObjectsCmd.MarkFlagRequired(dropObjectsFlag)
|
|
|
|
}
|