2022-06-02 12:07:30 +00:00
|
|
|
package storagegroup
|
|
|
|
|
|
|
|
import (
|
2022-12-23 17:35:35 +00:00
|
|
|
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
|
|
objectCli "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/object"
|
2023-01-16 09:20:16 +00:00
|
|
|
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
2022-12-23 17:35:35 +00:00
|
|
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
|
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
2022-06-02 12:07:30 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var sgDelCmd = &cobra.Command{
|
|
|
|
Use: "delete",
|
2023-01-27 10:44:39 +00:00
|
|
|
Short: "Delete storage group from FrostFS",
|
|
|
|
Long: "Delete storage group from FrostFS",
|
2022-06-02 12:07:30 +00:00
|
|
|
Run: delSG,
|
|
|
|
}
|
|
|
|
|
|
|
|
func initSGDeleteCmd() {
|
|
|
|
commonflags.Init(sgDelCmd)
|
|
|
|
|
|
|
|
flags := sgDelCmd.Flags()
|
|
|
|
|
2022-10-18 11:43:04 +00:00
|
|
|
flags.String(commonflags.CIDFlag, "", commonflags.CIDFlagUsage)
|
|
|
|
_ = sgDelCmd.MarkFlagRequired(commonflags.CIDFlag)
|
2022-06-02 12:07:30 +00:00
|
|
|
|
2022-10-11 14:02:03 +00:00
|
|
|
flags.StringVarP(&sgID, sgIDFlag, "", "", "Storage group identifier")
|
2022-06-02 12:07:30 +00:00
|
|
|
_ = sgDelCmd.MarkFlagRequired(sgIDFlag)
|
|
|
|
}
|
|
|
|
|
|
|
|
func delSG(cmd *cobra.Command, _ []string) {
|
|
|
|
pk := key.GetOrGenerate(cmd)
|
|
|
|
|
|
|
|
var cnr cid.ID
|
|
|
|
var obj oid.ID
|
|
|
|
|
|
|
|
addr := readObjectAddress(cmd, &cnr, &obj)
|
|
|
|
|
|
|
|
var prm internalclient.DeleteObjectPrm
|
2022-10-20 09:40:33 +00:00
|
|
|
objectCli.OpenSession(cmd, &prm, pk, cnr, &obj)
|
2022-06-02 12:07:30 +00:00
|
|
|
objectCli.Prepare(cmd, &prm)
|
|
|
|
prm.SetAddress(addr)
|
|
|
|
|
|
|
|
res, err := internalclient.DeleteObject(prm)
|
2023-01-16 09:20:16 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
2022-06-02 12:07:30 +00:00
|
|
|
|
|
|
|
tombstone := res.Tombstone()
|
|
|
|
|
|
|
|
cmd.Println("Storage group removed successfully.")
|
|
|
|
cmd.Printf(" Tombstone: %s\n", tombstone)
|
|
|
|
}
|