[#988] cli: Add subnet
flag to container create
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
acf7331034
commit
6207a2f261
1 changed files with 18 additions and 0 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/policy"
|
"github.com/nspcc-dev/neofs-sdk-go/policy"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
|
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||||
versionSDK "github.com/nspcc-dev/neofs-sdk-go/version"
|
versionSDK "github.com/nspcc-dev/neofs-sdk-go/version"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -54,6 +55,7 @@ var (
|
||||||
containerAwait bool
|
containerAwait bool
|
||||||
containerName string
|
containerName string
|
||||||
containerNoTimestamp bool
|
containerNoTimestamp bool
|
||||||
|
containerSubnet string
|
||||||
|
|
||||||
containerID string
|
containerID string
|
||||||
|
|
||||||
|
@ -127,6 +129,11 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
placementPolicy, err := parseContainerPolicy(containerPolicy)
|
placementPolicy, err := parseContainerPolicy(containerPolicy)
|
||||||
exitOnErr(cmd, err)
|
exitOnErr(cmd, err)
|
||||||
|
|
||||||
|
subnetID, err := parseSubnetID(containerSubnet)
|
||||||
|
exitOnErr(cmd, errf("could not parse subnetID: %w", err))
|
||||||
|
|
||||||
|
placementPolicy.SetSubnetID(subnetID)
|
||||||
|
|
||||||
attributes, err := parseAttributes(containerAttributes)
|
attributes, err := parseAttributes(containerAttributes)
|
||||||
exitOnErr(cmd, err)
|
exitOnErr(cmd, err)
|
||||||
|
|
||||||
|
@ -440,6 +447,7 @@ func initContainerCreateCmd() {
|
||||||
flags.BoolVar(&containerAwait, "await", false, "block execution until container is persisted")
|
flags.BoolVar(&containerAwait, "await", false, "block execution until container is persisted")
|
||||||
flags.StringVar(&containerName, "name", "", "container name attribute")
|
flags.StringVar(&containerName, "name", "", "container name attribute")
|
||||||
flags.BoolVar(&containerNoTimestamp, "disable-timestamp", false, "disable timestamp container attribute")
|
flags.BoolVar(&containerNoTimestamp, "disable-timestamp", false, "disable timestamp container attribute")
|
||||||
|
flags.StringVar(&containerSubnet, "subnet", "", "string representation of container subnetwork")
|
||||||
}
|
}
|
||||||
|
|
||||||
func initContainerDeleteCmd() {
|
func initContainerDeleteCmd() {
|
||||||
|
@ -569,6 +577,16 @@ func prettyPrintContainerList(cmd *cobra.Command, list []*cid.ID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseSubnetID(val string) (sub *subnetid.ID, err error) {
|
||||||
|
sub = &subnetid.ID{}
|
||||||
|
|
||||||
|
if val != "" {
|
||||||
|
err = sub.UnmarshalText([]byte(val))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error) {
|
func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error) {
|
||||||
_, err := os.Stat(policyString) // check if `policyString` is a path to file with placement policy
|
_, err := os.Stat(policyString) // check if `policyString` is a path to file with placement policy
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in a new issue