diff --git a/cmd/neofs-cli/modules/storagegroup/put.go b/cmd/neofs-cli/modules/storagegroup/put.go index f5d7244ca9..4dce711f5e 100644 --- a/cmd/neofs-cli/modules/storagegroup/put.go +++ b/cmd/neofs-cli/modules/storagegroup/put.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/ecdsa" "errors" + "strconv" internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client" "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common" @@ -42,6 +43,9 @@ func initSGPutCmd() { flags.StringSliceVarP(&sgMembers, sgMembersFlag, "m", nil, "ID list of storage group members") _ = sgPutCmd.MarkFlagRequired(sgMembersFlag) + + flags.Uint64(sgLifetimeFlag, 0, "Storage group lifetime in epochs") + _ = sgPutCmd.MarkFlagRequired(sgLifetimeFlag) } func putSG(cmd *cobra.Command, _ []string) { @@ -53,6 +57,10 @@ func putSG(cmd *cobra.Command, _ []string) { var cnr cid.ID readCID(cmd, &cnr) + lifetimeStr := cmd.Flag(sgLifetimeFlag).Value.String() + lifetime, err := strconv.ParseUint(lifetimeStr, 10, 64) + common.ExitOnErr(cmd, "could not parse lifetime: %w", err) + members := make([]oidSDK.ID, len(sgMembers)) for i := range sgMembers { @@ -78,6 +86,16 @@ func putSG(cmd *cobra.Command, _ []string) { }, cnr, members) common.ExitOnErr(cmd, "could not collect storage group members: %w", err) + cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC) + + var netInfoPrm internalclient.NetworkInfoPrm + netInfoPrm.SetClient(cli) + + ni, err := internalclient.NetworkInfo(netInfoPrm) + common.ExitOnErr(cmd, "can't fetch network info: %w", err) + + sg.SetExpirationEpoch(ni.NetworkInfo().CurrentEpoch() + lifetime) + obj := object.New() obj.SetContainerID(cnr) obj.SetOwnerID(&ownerID) diff --git a/cmd/neofs-cli/modules/storagegroup/root.go b/cmd/neofs-cli/modules/storagegroup/root.go index 534bbffe05..5b5d58654d 100644 --- a/cmd/neofs-cli/modules/storagegroup/root.go +++ b/cmd/neofs-cli/modules/storagegroup/root.go @@ -25,6 +25,8 @@ const ( cidFlag = "cid" ) +const sgLifetimeFlag = "lifetime" + func init() { storageGroupChildCommands := []*cobra.Command{ sgPutCmd,