与ecs管理api交互的库
python-ecsclient的Python项目详细描述
这个库是用于Dell EMC Elastic Cloud Storage (ECS)的python软件开发工具包(sdk)。 它允许开发人员与ecs管理api交互。你可以找到 ecs api规范here。
这个库是ECS Minion的后续库。
快速启动
您可以使用pip安装python-ecsclient。
$ pip install python-ecsclient
创建ecsclient类的实例允许 参数:
Name | Required | Default Value | Description |
---|---|---|---|
^{tt2}$ | Yes | None | Version of the target ECS system. Options are ^{tt3}$ and ^{tt4}$ |
^{tt5}$ | No | None | The username used to fetch the ECS token |
^{tt6}$ | No | None | The password used to fetch the ECS token |
^{tt7}$ | No | None | Pass a token to ECSClient (username/password are ignored then) |
^{tt8}$ | Yes | None | The ECS API endpoint, ex: ^{tt9}$ |
^{tt10}$ | No | None | The ECS API endpoint, ex: ^{tt11}$ |
^{tt12}$ | No | False | Whether to check a host’s SSL certificate |
^{tt13}$ | No | ^{tt14}$ | The location to store the temporary token file |
^{tt15}$ | No | 15.0 | Stop waiting for a response after a given number of seconds, this is a decimal value. Ex: 10.0 is ten seconds |
^{tt16}$ | No | True | Whether to cache the token, by default this is true you should only switch this to false when you want to directly fetch a token for a user |
这就是如何实例化Client类并使用库的方法。
fromecsclient.clientimportClientclient=Client('3',username='ecsadmin@internal',password='PASSWORD',token_endpoint='https://192.168.0.149:4443/login',ecs_endpoint='https://192.168.0.149:4443')print(client.user_info.whoami())
查看我们的documentation以查找所有受支持的ecs端点和服务的列表。
提供代币
您可以将身份验证令牌直接传递给客户端,这意味着您 不需要提供用户名/密码。
client=Client('3',token='ALAcbGZtbjh6eVB3eUF1TzFEZWNmc0M2VVl2QjBVPQM',ecs_endpoint='https://192.168.1.146:4443')
令牌缓存
默认情况下,客户端缓存身份验证令牌。但是你可以禁用缓存 通过将cache_token参数设置为false。
client=Client('3',username='someone',password='password',token_endpoint='https://192.168.1.146:4443/login',ecs_endpoint='https://192.168.1.146:4443',cache_token=False)
或者,如果启用了令牌缓存,则可能需要强制客户端 在下次调用时获取新令牌。为此,可以删除缓存的令牌。
client.remove_cached_token()
支持的终结点
下表显示了每个API版本支持的终结点。
v2 | v3 | |
---|---|---|
Configuration | ||
Certificate | ✓ | ✓ |
Configuration Properties | ✓* | ✓* |
Licensing | ✓ | ✓ |
Feature | ✓ | ✓ |
Syslog | ✓* | |
Snmp | ✓* | |
CAS | ||
CAS User Profile | ✓* | ✓* |
File System Access | ||
NFS | ✗ | ✗ |
Metering | ||
Billing | ~ | ~ |
Migration | ||
Transformation | ✗ | ✗ |
Monitoring | ||
Capacity | ✓ | ✓ |
Dashboard | ✓* | ✓* |
Events | ✓* | ✓* |
Alerts | ✓* | ✓* |
Multi-tenancy | ||
Namespace | ✓* | ✓* |
Geo-Replication | ||
Replication Group | ✓ | ✓ |
Temporary Failed Zone | ✓* | ✓* |
Provisioning | ||
Base URL | ✓* | ✓* |
Bucket | ✓* | ✓ |
Data Store | ✓* | ✓ |
Node | ~ | ~ |
Storage Pool | ✓ | ✓ |
Virtual Data Center | ✓ | ✓ |
VDC Keystore | ✓ | ✓ |
Support | ||
Call Home | ✗ | ✗ |
User Management | ||
Authentication Provider | ~ | ~ |
Password Group (Swift) | ✓ | ✓ |
Secret Key | ✓ | ✓ |
Secret Key Self-Service | ✓ | ✓ |
User (Object) | ✓ | ✓ |
User (Management) | ✓* | ✓ |
Other | ||
Who am I | ✓ | ✓ |
图例:
✓ | Supported and tested |
✓* | Supported but not tested yet |
~ | Partially supported |
✗ | Not supported yet |
Not available in this API version |
开发
开始
假设您安装了python和virtualenv,请设置 环境并安装所需的依赖项,而不是 上面定义的pip install python-ecsclient:
$ git clone https://github.com/EMCECS/python-ecsclient.git
$ cd python-ecsclient
$ virtualenv venv
...
$ . venv/bin/activate
$ pip install -r requirements.txt
运行测试
您可以使用tox在所有受支持的python版本中运行测试。默认情况下, 它将运行所有单元测试,但您也可以指定自己的 nosetests选项。请注意,这要求您 安装了python的版本,否则必须传递-e,或运行 nosetests直接命令:
$ tox $ tox -e py27,py35 tests/functional
您还可以使用默认的python版本运行单独的测试:
$ nosetests tests/unit