Giter Site home page Giter Site logo

shirosaidev / diskover-storage-agent Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 35 KB

A simple http server for running on storage nodes to return dir lists

License: Apache License 2.0

Python 100.00%
python storage http-server filesystem api load-balancer listdir

diskover-storage-agent's Introduction

diskover-storage-agent

A simple http server for running on storage nodes to return dir lists. Can be run on multiple storage nodes for load balancing requests.

Requirements

  • Python 2.6+
  • scandir.py (in repo, for server only)
  • requests python module (only needed for client diskover_agent module)

Usage

Copy diskover_storage_agent.py and scandir.py to one or multiple nodes (for example stornode1, stornode2) on your storage cluster.

To start the http server (storage agent) on each node, run:

$ python diskover_storage_agent.py -r /mnt/isilon /ifs/data
Usage: diskover_storage_agent.py [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -l LISTEN, --listen=LISTEN
                        IP address for diskover storage agent to listen on
                        (default: 0.0.0.0)
  -p PORT, --port=PORT  Port for diskover storage agent (default: 9999)
  -c MAXCONNECTIONS, --maxconnections=MAXCONNECTIONS
                        Maximum number of connections (default: 50)
  -r PATH PATH, --replacepath=PATH PATH
                        Replace paths from remote to local,
                        example: -r /mnt/share/ /ifs/data/
  -v, --verbose         Increase verbosity (specify multiple times for more)

Example to access the http agents in python import diskover_agent.py module:

>>> import diskover_agent
>>> hostlist = ['stornode1', 'stornode2']
>>> c = diskover_agent.AgentConnection(hosts=hostlist)
>>> c.hostlist()
['stornode1', 'stornode2']
>>> c.connect()
>>> c.conn_host()
stornode1
>>> c.listdir('/mnt/isilon/somedir')
('/mnt/isilon/somedir', ['subdir1', 'subdir2'], ['file1.ext', 'file2.ext'])
>>> c.response_time()
0.0198
>>> c.connect()
>>> c.conn_host()
stornode2
>>> c.listdir('/mnt/isilon/someotherdir')
('/mnt/isilon/someotherdir', ['subdira', 'subdirb'], ['filea.ext', 'fileb.ext'])
>>> c.response_time()
0.0182
>>> from diskover_agent import parallel_walk as pwalk
>>> pwalk('/mnt/isilon/somedir', workers=40, hosts=hostlist)
<generator object parallel_walk at 0x1038869b0>
for root, dirs, files in pwalk('/mnt/isilon/somedir', workers=40, hosts=hostlist):
...     print(root, dirs, files)
('/mnt/isilon/somedir', ['subdir1', 'subdir2'], ['file1.ext', 'file2.ext'])
('/mnt/isilon/somedir/subdir1', [], ['file.ext'])

Example using curl:

$ curl http://stornode1:9999/mnt/isilon/somedir
file1.ext
file2.ext
subdir1/
subdir2/

diskover-storage-agent's People

Contributors

shirosaidev avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

macropower

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.