nspcc-dev / neofs-node

NeoFS is a decentralized distributed object storage integrated with the Neo blockchain
https://fs.neo.org
GNU General Public License v3.0
32 stars 38 forks source link

Neofs-cli: Add `container search` method to get containers with target attribute #1882

Open anatoly-bogatyrev opened 1 year ago

anatoly-bogatyrev commented 1 year ago

Problem

With a large number of containers (more than a few hundred), it becomes very difficult to find the target container. We have to make container get command request to check all of them one by one or use container list --with-attr in combination with grep now. But this is not the most convenient approach.

It would be good to simplify the management of containers by adding the ability to search by attributes.

Solution

Add container search command to find containers with specific attribute.

For example:

$ neofs-cli --rpc-endpoint node1.neofs:8080 -w scenarios/files/wallet.json container search --filter 'Name EQ test'  
Enter password > 
JCsuK9R8MLR35yD257BmPxmDZ52UuWuhUwswUG4nr8h6

$ neofs-cli --rpc-endpoint node1.neofs:8080 -w scenarios/files/wallet.json container get --cid JCsuK9R8MLR35yD257BmPxmDZ52UuWuhUwswUG4nr8h6
Enter password > 
container ID: JCsuK9R8MLR35yD257BmPxmDZ52UuWuhUwswUG4nr8h6
owner ID: Nge3U4wJpDGK2BWGfH5VcZ5PAbC6Ro7GHY
basic ACL: fbfbfff (eacl-public-read-write)
created: 2022-10-06 17:28:20 +0300 MSK
attributes:
    Timestamp=1665066500
    __NEOFS__NAME=test
    __NEOFS__ZONE=container
    Name=b0cfaae3-ed18-4ba2-9074-2b246bec8c26
    .s3-location-constraint=load-1-1
    __NEOFS__DISABLE_HOMOMORPHIC_HASHING=true
placement policy:
REP 1
CBF 1
SELECT 1 FROM *

$ neofs-cli --rpc-endpoint node1.neofs:8080 -w scenarios/files/wallet.json container search --filter '.s3-location-constraint NOPRESENT'  
Enter password > 
6RLC6wB49XetQNz9at9zopXan7SGuWyKqpk7FX31XBi
Gghm73EPsZSW1uxo759hiyrRrptkhLYaJBMBX4oCg9Yf
H2vR3MaoWAj2rA9dpgJsLBJnXiPRq9pEU7U5t7pBFBVh
HDd9N5mrPeEbjmiNLw6DrtZiMxUPQhDSWwUb9RL8cM85
HN9kdtg5DkFdFS36A6pgNbca5fVTMSTQgNaapzJ6QWeN
cthulhu-rider commented 1 year ago

It doesn't seem convenient to have flex QL for limited needs. So lets provide container search --name test instead of container search --filter 'Name EQ test'.

roman-khimov commented 1 year ago

We can have named containers with NNS, so if we're talking names only, it's solved. Attributes are a bit different though.