forked from TrueCloudLab/frostfs-node
[#175] adm: list containers using containersOf
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
8e5a0dcf27
commit
e85e5382e4
1 changed files with 17 additions and 5 deletions
|
@ -42,15 +42,27 @@ func getContainerContractHash(cmd *cobra.Command, inv *invoker.Invoker, c Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContainersList(inv *invoker.Invoker, ch util.Uint160) ([][]byte, error) {
|
func getContainersList(inv *invoker.Invoker, ch util.Uint160) ([][]byte, error) {
|
||||||
res, err := inv.Call(ch, "list", "")
|
sid, r, err := unwrap.SessionIterator(inv.Call(ch, "containersOf", ""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
|
return nil, fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
|
||||||
}
|
}
|
||||||
itm, err := unwrap.Item(res, err)
|
// Nothing bad, except live session on the server, do not report to the user.
|
||||||
if _, ok := itm.(stackitem.Null); !ok {
|
defer func() { _ = inv.TerminateSession(sid) }()
|
||||||
return unwrap.ArrayOfBytes(res, err)
|
|
||||||
|
var lst [][]byte
|
||||||
|
|
||||||
|
items, err := inv.TraverseIterator(sid, &r, 0)
|
||||||
|
for err == nil && len(items) != 0 {
|
||||||
|
for j := range items {
|
||||||
|
b, err := items[j].TryBytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
|
||||||
}
|
}
|
||||||
return nil, nil
|
lst = append(lst, b)
|
||||||
|
}
|
||||||
|
items, err = inv.TraverseIterator(sid, &r, 0)
|
||||||
|
}
|
||||||
|
return lst, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpContainers(cmd *cobra.Command, _ []string) error {
|
func dumpContainers(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
Loading…
Reference in a new issue