将会计记录上传到eudat会计服务器
项目描述
将会计记录上传到eudat会计服务器
通过EUDAT通用数据基础设施提供的(存储)资源管理员可以使用此工具方便地报告注册资源当前资源消耗。会计记录是按每个由其(P)ID标识的资源提交的,该ID在资源在EUDAT的数据项目管理工具(DPMT)注册后即可获得。
默认设置是只需提供资源ID和消耗值。默认单位是字节,默认资源类型设置为存储。支持选项的完整文档将在下一节中描述。
如果这里提供的工具不能满足您的使用案例,您可以在问题跟踪器上提交功能请求,或者使用服务器文档中概述的更底层的方法。
完整文档和API
安装
安装此工具最简单的方法是通过pip或easy_install。通常最好在virtualenv中执行此操作。
$ pip install eudat.accounting.client
命令行界面
因此,现在有两个名为addRecord和iRODScollector的控制台脚本。使用-h调用它,以查看其用法模式和选项。
addRecord
$ bin/addRecord -h
usage: addRecord [-h] [--version] [-b BASE_URL] [-u USER] [-p PASSWORD]
[-d DOMAIN] [-s SERVICE] [-n NUMBER] [-o OBJECT_TYPE]
[-k KEY] [-T TYPE] [-m MEASURE_TIME] [-C COMMENT] [-t] [-v]
account value [unit]
positional arguments:
account account to be used. Typically the (P)ID of the
resource to be accounted
value The value to be recorded
unit The unit of measurement for the value provided.
Default: "byte"
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
-b BASE_URL, --base_url BASE_URL
base URL of the accounting server to use. Default:
https://accounting.eudat.eu
-u USER, --user USER user id used for logging into the server. If not
provided it is looked up in the environment variable
"ACCOUNTING_USER". Default: "" - aka not set
-p PASSWORD, --password PASSWORD
password used for logging into the server. If not
provided it is looked up in the environment variable
"ACCOUNTING_PW". Default: "" - aka not set
-d DOMAIN, --domain DOMAIN
name of the domain holding the account. Default: eudat
-s SERVICE, --service SERVICE
UID (or PID) of the registered service component
reporting the record. Default: "" - not set
-n NUMBER, --number NUMBER
number of objects associated with this accounting
record. This is EUDAT specific. Default: "" - not set
-o OBJECT_TYPE, --object_type OBJECT_TYPE
object type for the number of objects specified with
"-n". This is EUDAT specific. Default: "registered
objects"
-k KEY, --key KEY key used to refer to the record. If not set the
accounting server will create the key. Specifying an
existing key will overwrite the existing record.
Default: "" - not set
-T TYPE, --type TYPE type of the resource accounted. Default: storage
-m MEASURE_TIME, --measure_time MEASURE_TIME
measurement time of the accounting record if different
from the current time. Default: "" - not set
-C COMMENT, --comment COMMENT
arbitrary comment (goes into the meta dictionary).
Default: "" - not set
-t, --test Dry run. Don't push data to server - run only locally
Default: off
-v, --verbose return the key of the accounting record created.
Default: off
iRODScollector
$ bin/iRODScollector -h
usage: iRODScollector [-h] [--version] [-c CONFIGPATH] [-k KEY] [-T TYPE]
[-m MEASURE_TIME] [-C COMMENT] [-t] [-v]
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
-c CONFIGPATH, --configpath CONFIGPATH
path to configuration file. Default:
"./irodscollector.cfg" (in the current working
directory)
-k KEY, --key KEY key used to refer to the record. If not set the
accounting server will create the key. Specifying an
existing key will overwrite the existing record.
Default: "" - not set
-T TYPE, --type TYPE type of the resource accounted. Default: storage
-m MEASURE_TIME, --measure_time MEASURE_TIME
measurement time of the accounting record if different
from the current time. Default: "" - not set
-C COMMENT, --comment COMMENT
arbitrary comment (goes into the meta dictionary).
Default: "" - not set
-t, --test Dry run. Don't push data to server - run only locally
Default: off
-v, --verbose return the key of the accounting record created.
Default: off
分发中包含一个模板配置文件,其外观如下所示
$ cat irodscollector.ini
#
# template of a configuration file for EUDAT's irodscollector
#
# section containing the logging options
[Logging]
log_file=eudatacct.log
# section containing the properties to access the accounting server
# to get statistical data and report them
[Report]
# base URL of the accounting server to be used
base_url=https://accounting.eudat.eu
# domain: either eudat or test or demo
domain=eudat
# uid of the corresponding registered storage resource on DPMT
# (same as storage_space_uuid on RCT)
account=<insert uid here>
# username of the provider on the accouniting server
# owning the account specified above
# contact dp-admin@mpcdf.mpg.de if you need one
user=<username of provider>
# if you have an access token from RCT already reuse that here
password=<password or access token>
service_uuid=<unsuported at the moment>
# section contains the list of collections to be accounted together, replace
# the examples with your collections, the script sums the values of all
# collections and sends it to EUDAT's accounting service.
[Collections]
clist=
/zone/some/path
/zone/other/path
将其复制到 irodscollector.cfg 并根据您的站点进行调整。
其中大部分应该是自我解释的。请注意,您需要为会计服务提供凭据。如果您没有,请联系 EUDAT 会计经理。
此外,您需要确保调用此脚本的用户已设置合适的 iRODS 环境。
基本使用信息和错误消息记录到当前工作目录中名为 .accounting.log 的文件中,从该目录调用 addRecord。
开发者说明
请使用 virtualenv 维护此软件包,但我觉得无需多言。
该软件包可以直接从 GitHub 安装
$ pip install git+git://github.com/EUDAT-DPMT/eudat.accounting.client
代码组织在一个嵌套的命名空间包中,即实际操作发生在子目录中
$ cd src/eudat/accounting/client
开始在那里查找。
运行测试(目前还没有什么意义)
$ python setup.py test
$ python run_tests.py
链接
项目主页
源代码
问题跟踪器
https://github.com/EUDAT-DPMT/eudat.accounting.client/issues
1.0.1 (2017-08-25)
addRecord 现在也支持干燥运行选项 ‘-t’ 这解决了问题 #3 [raphael-ritz]
1.0.0 (2017-03-15)
根据 Claudio 和 Pavel 的工作添加 iRODScollector [raphael-ritz]
Python 3 兼容性 [raphael-ritz]
1.0.0rc1 (2016-07-22)
初始发布 [raphael-ritz]
项目详情
下载文件
下载您平台上的文件。如果您不确定要选择哪个,请了解更多关于 安装软件包 的信息。
源代码分发
eudat.accounting.client-1.0.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1214ab1106b0928ffdbbba9c13cc46bfb6adad0f7cb932e67ff99770b475f94b |
|
MD5 | 383b5358e674eecab0ca73b91e7f946a |
|
BLAKE2b-256 | 54e9815414be33c94e76ce71ba8e614442ab3666df235f38c470970a55a77799 |