forked from TrueCloudLab/frostfs-node
[#1513] Upgrade NeoFS SDK Go with changed netmap
package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
24b4c1ecf4
commit
21d2f8f861
70 changed files with 878 additions and 992 deletions
|
@ -16,7 +16,6 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/acl"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/container"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/policy"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
|
@ -69,12 +68,14 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
|||
placementPolicy, err := parseContainerPolicy(containerPolicy)
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
||||
var subnetID subnetid.ID
|
||||
if containerSubnet != "" {
|
||||
var subnetID subnetid.ID
|
||||
|
||||
err = subnetID.DecodeString(containerSubnet)
|
||||
common.ExitOnErr(cmd, "could not parse subnetID: %w", err)
|
||||
err = subnetID.DecodeString(containerSubnet)
|
||||
common.ExitOnErr(cmd, "could not parse subnetID: %w", err)
|
||||
|
||||
placementPolicy.SetSubnetID(&subnetID)
|
||||
placementPolicy.RestrictSubnet(subnetID)
|
||||
}
|
||||
|
||||
attributes, err := parseAttributes(containerAttributes)
|
||||
common.ExitOnErr(cmd, "", err)
|
||||
|
@ -177,16 +178,17 @@ func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error)
|
|||
policyString = string(data)
|
||||
}
|
||||
|
||||
result, err := policy.Parse(policyString)
|
||||
var result netmap.PlacementPolicy
|
||||
|
||||
err = result.DecodeString(policyString)
|
||||
if err == nil {
|
||||
common.PrintVerbose("Parsed QL encoded policy")
|
||||
return result, nil
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
result = netmap.NewPlacementPolicy()
|
||||
if err = result.UnmarshalJSON([]byte(policyString)); err == nil {
|
||||
common.PrintVerbose("Parsed JSON encoded policy")
|
||||
return result, nil
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
return nil, errors.New("can't parse placement policy")
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
|
||||
|
@ -12,7 +11,6 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/acl"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/container"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/policy"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -85,6 +83,13 @@ func initContainerInfoCmd() {
|
|||
flags.BoolVar(&containerJSON, "json", false, "print or dump container in JSON format")
|
||||
}
|
||||
|
||||
type stringWriter cobra.Command
|
||||
|
||||
func (x *stringWriter) WriteString(s string) (n int, err error) {
|
||||
(*cobra.Command)(x).Print(s)
|
||||
return len(s), nil
|
||||
}
|
||||
|
||||
func prettyPrintContainer(cmd *cobra.Command, cnr *container.Container, jsonEncoding bool) {
|
||||
if cnr == nil {
|
||||
return
|
||||
|
@ -137,8 +142,14 @@ func prettyPrintContainer(cmd *cobra.Command, cnr *container.Container, jsonEnco
|
|||
cmd.Println("invalid nonce:", err)
|
||||
}
|
||||
|
||||
cmd.Println("placement policy:")
|
||||
cmd.Println(strings.Join(policy.Encode(cnr.PlacementPolicy()), "\n"))
|
||||
pp := cnr.PlacementPolicy()
|
||||
if pp == nil {
|
||||
cmd.Println("missing placement policy")
|
||||
} else {
|
||||
cmd.Println("placement policy:")
|
||||
common.ExitOnErr(cmd, "write policy: %w", pp.WriteStringTo((*stringWriter)(cmd)))
|
||||
cmd.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func prettyPrintBasicACL(cmd *cobra.Command, basicACL acl.BasicACL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue