对象存储接口

pfstorage1的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 Swing定时器和线程&For循环中只执行最后一个命令   java使用@query使用Spring数据创建自定义查询   java如何在多模块Maven项目中自动重用依赖项版本?   java Mongo/JPA IllegalArgumentException解析地理本机查询   accesscontrolexception java。伊奥。从“user.dir”读取时的文件权限   mysql我可以将表名作为参数传递给java准备的语句吗?   java从当前livy会话访问数据文件   运行JUnit测试时未找到java类异常   当来自其他包的类失败时,java方法调用失败   java Tomcat服务器显示无法启动   DB事务分组Spring,java寻找设计思路   java testng。xml未运行类   带图像的java fillRect方法   java使用RecyclerView显示项目,每个项目都带有一个按钮,该按钮应启动不同的RecyclerView   Java在for循环中的hashmap中放置了一些内容