对象存储接口

pfstorage的Python项目详细描述


https://badge.fury.io/py/pfstorage.svghttps://travis-ci.org/FNNDSC/pfstorage.svg?branch=masterhttps://img.shields.io/badge/python-3.5%2B-blue.svg

Overview

这个存储库提供pfstorage–一个库/模块,它与对象存储后端(例如swift)通信,并且还提供处理chris系统的输入/输出数据位置的逻辑。

pfstorage

最简单的是,pfstorage是一个模块,它提供了一个到其他后端对象存储的正则化接口。虽然目前支持swift,但长期的想法是支持大量后端。通过向多个存储后端提供自己的接口,该模块消除了使用不同对象存储后端时更改客户端代码的需要。

虽然其核心是模块/库,pfstorage还提供了两种独立访问模式:(1)命令行脚本与库的接口模式,以及(2)持久http服务器模式。在命令行模式下,主模块功能将公开给相应的cli。在http服务器模式下,客户机可以使用curl类型http调用来调用底层库函数。

Installation

安装相对简单,我们建议使用python虚拟环境或docker。

Python Virtual Environment

在ubuntu上,安装python virtual environment creator

sudo apt install virtualenv

然后,为您的虚拟环境创建一个目录,例如:

mkdir ~/python-envs

您可能需要将这两行代码添加到.bashrc文件中:

exportWORKON_HOME=~/python-envs
source /usr/local/bin/virtualenvwrapper.sh

请注意,根据发行版的不同,virtualenvwrapper.sh路径可能是

/usr/share/virtualenvwrapper/virtualenvwrapper.sh

随后,您可以获得.bashrc并创建一个新的python3虚拟环境:

source .bashrc
mkvirtualenv --python=python3 python_env

激活或“输入”虚拟环境:

workon python_env

要停用虚拟环境:

deactivate

Using the ^{tt1}$ docker container

不过,最简单的选择是使用fnndsc/pfstoragedock。

docker pull fnndsc/pfstorage

然后运行(例如在http服务器模式下访问库):

docker run --name pfstorage -v /home:/Users --rm -ti \
       fnndsc/pfstorage \
       --ipSwift localhost \
       --portSwift 8080\
       --forever \
       --httpResponse \
       --server

或在cli模式下:

docker run --name pfstorage -v /home:/Users --rm -ti \
       fnndsc/pfstorage \
       --ipSwift localhost \
       --portSwift 8080\
       --msg '
        { "action": "ls",
          "meta": {
                        "path":         "",
                        "retSpec":      ["name", "bytes"]
                  }
        }'

Usage

有关pfstorage的用法,请参阅相关的wiki页面<;https://github.com/FNNDSC/pfstorage/wiki/pfcon-overview>;`。

Command line arguments

--msg '<JSON_formatted>'
The action to perform. This can be one of:

    * objPull -- pull data from storage to file system
    * objPush -- push data from file system to storage
    * ls      -- listing of data within storage

with a JSON formatted string similar to:

    * ls:
    { "action": "ls",
      "meta": {
                    "path":         "",
                    "retSpec":      ["name", "bytes"]
              }
    }

    * objPut:
    {  "action": "objPut",
        "meta": {
                    "putSpec":              "./data",
                    "inLocation":           "storage",
                    "mapLocationOver":      "./data"
                }
    }

    * objPull:
    {  "action": "objPull",
        "meta": {
                    "path":                 "chris",
                    "substr":               "/018",
                    "fromLocation":         "chris/uploads/DICOM",
                    "mapLocationOver":      "./data"
                }
    }

[--type <storageBackendType>]
The type of object storage. Currently this is 'swift'.

[--ipSwift <swiftIP>]
The IP interface of the object storage service. Default %s.

[--portSwift <swiftPort>]
The port of the object storage service. Defaults to '8080'.

[--ipSelf <selfIP>]
The IP interface of the pfstorage service for server mode. Default %s.

[--portSelf <selfPort>]
The port of the pfstorage service for server mode. Defaults to '4055'.

[--httpResponse]
In servier mode, send return strings as HTTP formatted replies
with content-type html.

[--configFileLoad <file>]
Load configuration information from the JSON formatted <file>.

[--configFileSave <file>]
Save configuration information to the JSON formatted <file>.

[-x|--desc]
Provide an overview help page.

[-y|--synopsis]
Provide a synopsis help summary.

[--version]
Print internal version number and exit.

[--debugToDir <dir>]
A directory to contain various debugging output -- these are typically
JSON object strings capturing internal state. If empty string (default)
then no debugging outputs are captured/generated. If specified, then
``pfcon`` will check for dir existence and attempt to create if
needed.

[-v|--verbosity <level>]
Set the verbosity level. "0" typically means no/minimal output. Allows for
more fine tuned output control as opposed to '--quiet' that effectively
silences everything.

EXAMPLES

script mode

pfstorage                                               \
    --ipSwift localhost                                 \
    --portSwift 8080\
    --verbosity 1\
    --debugToDir /tmp                                   \
    --type swift                                        \
    --msg '
    {
        "action":   "ls",
        "meta": {
            "path":         "",
            "retSpec":      ["name", "bytes"]
        }
    }
    '

server mode

启动服务器

pfstorage                                               \
    --ipSwift localhost                                 \
    --portSwift 8080\
    --ipSelf localhost                                  \
    --portSelf 4055\
    --httpResponse                                      \
    --verbosity 1\
    --debugToDir /tmp                                   \
    --type swift                                        \
    --server                                            \
    --forever

查询服务器

pfurl --verb POST --raw                                 \
      --http localhost:4055/api/v1/cmd                  \
      --httpResponseBodyParse                           \
      --jsonwrapper 'payload'\
      --msg '
            {
                "action":   "ls",
                "meta": {
                    "path":         "",
                    "retSpec":      ["name", "bytes"]
                }
            }
    '

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java数独生成器循环   java如何使用Executor创建Jersey 2客户端   java调用阅读器。在DigitalPersona U.are中捕获()。U SDK不返回   安卓 studio中未找到java类错误   基于颜色对象的java Set Excel样式(背景)   MongoDB java更新为空数组   java无法在安卓 studio中解析XML错误   java JGit签出上一次提交   java在从9.0.1升级到google play services 9.4.0后出现错误。getMap();   动态计时器JAVA setTitle   java SchedulingConfigurer/CronTrigger正则表达式未按预期工作   蓝牙低能耗为什么Java TinyB看不到与hcitool相同的设备?   swing手工编码GUI Java