-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
neofs-cli/control: add
object list
control command
Support command that gets list of objects in node. Create separate file for `control object` commands. ``` $ neofs-cli control object list --endpoint s01.neofs.devenv:8081 -w services/storage/wallet01.json Enter password > A2FtcmZh76XqAym55fkCvzfB7dJ5dUt3fuGzQitGkW7S/CxSt4cFbwMtnuKHjqEjsWjctdfVWWTZqLkXheLHxjn4p HimRwmgw4PNasobAxGwVMCmV45rkjvYkYdV7toDoavMu/2YCzyvgz9HMfyBAAbGNmcsq98serp77hzJuc6F4qSz5w HimRwmgw4PNasobAxGwVMCmV45rkjvYkYdV7toDoavMu/2hgSnzrZHaQZLxLNXz4XEGbHdB9Y1zUjDZa3Z1foBnma $ neofs-cli control object list --endpoint s02.neofs.devenv:8081 -w services/storage/wallet02.json Enter password > HimRwmgw4PNasobAxGwVMCmV45rkjvYkYdV7toDoavMu/GrHcAXjgWiS69iVXBpe8YGKx1H23rBbfTCBL5WojaoSw $ neofs-cli control object list --endpoint s03.neofs.devenv:8081 -w services/storage/wallet03.json Enter password > A2FtcmZh76XqAym55fkCvzfB7dJ5dUt3fuGzQitGkW7S/5rTDeZTrgMt3DZE8nbT6sKFn1MiZUKZu4Gfk7cFrW7WY HimRwmgw4PNasobAxGwVMCmV45rkjvYkYdV7toDoavMu/2hgSnzrZHaQZLxLNXz4XEGbHdB9Y1zUjDZa3Z1foBnma HimRwmgw4PNasobAxGwVMCmV45rkjvYkYdV7toDoavMu/GrHcAXjgWiS69iVXBpe8YGKx1H23rBbfTCBL5WojaoSw 4rj9mynn8tijZFK9mgdG1Zc2fjwdEJstwYC2iYRM8skw/CRuojN8Lv6nzyoEfQ4FEPWdZxSSAtM2rqQPMuZLMePJQ A2FtcmZh76XqAym55fkCvzfB7dJ5dUt3fuGzQitGkW7S/CxSt4cFbwMtnuKHjqEjsWjctdfVWWTZqLkXheLHxjn4p HimRwmgw4PNasobAxGwVMCmV45rkjvYkYdV7toDoavMu/2YCzyvgz9HMfyBAAbGNmcsq98serp77hzJuc6F4qSz5w $ neofs-cli control object list --endpoint s04.neofs.devenv:8081 -w services/storage/wallet04.json Enter password > 4rj9mynn8tijZFK9mgdG1Zc2fjwdEJstwYC2iYRM8skw/CRuojN8Lv6nzyoEfQ4FEPWdZxSSAtM2rqQPMuZLMePJQ A2FtcmZh76XqAym55fkCvzfB7dJ5dUt3fuGzQitGkW7S/5rTDeZTrgMt3DZE8nbT6sKFn1MiZUKZu4Gfk7cFrW7WY ``` Closes #2853. Signed-off-by: Andrey Butusov <andrey@nspcc.io>
- Loading branch information
Showing
5 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package control | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var objectCmd = &cobra.Command{ | ||
Use: "object", | ||
Short: "Direct object operations with storage engine", | ||
} | ||
|
||
func initControlObjectsCmd() { | ||
objectCmd.AddCommand(listObjectsCmd) | ||
objectCmd.AddCommand(objectStatusCmd) | ||
|
||
initControlObjectsListCmd() | ||
initObjectStatusFlags() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package control | ||
|
||
import ( | ||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client" | ||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common" | ||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags" | ||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key" | ||
"github.com/nspcc-dev/neofs-node/pkg/services/control" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var listObjectsCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "List of all objects in the storage node", | ||
Long: "List of all objects in the storage node", | ||
Args: cobra.NoArgs, | ||
Run: listObjects, | ||
} | ||
|
||
func initControlObjectsListCmd() { | ||
initControlFlags(listObjectsCmd) | ||
} | ||
|
||
func listObjects(cmd *cobra.Command, _ []string) { | ||
ctx, cancel := commonflags.GetCommandContext(cmd) | ||
defer cancel() | ||
|
||
pk := key.Get(cmd) | ||
|
||
req := &control.ListObjectsRequest{ | ||
Body: &control.ListObjectsRequest_Body{}, | ||
} | ||
signRequest(cmd, pk, req) | ||
|
||
cli := getClient(ctx, cmd) | ||
|
||
var resp *control.ListObjectsResponse | ||
var err error | ||
err = cli.ExecRaw(func(client *rawclient.Client) error { | ||
resp, err = control.ListObjects(client, req) | ||
return err | ||
}) | ||
common.ExitOnErr(cmd, "rpc error: %w", err) | ||
|
||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody()) | ||
|
||
objects := resp.GetBody().GetObjects() | ||
if len(objects) == 0 { | ||
cmd.Println("<empty response>") | ||
} | ||
|
||
for _, object := range objects { | ||
cmd.Println(object.GetAddress()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters