solidfire python开发包
solidfire-sdk-python的Python项目详细描述
用于与solidfire元素api交互的python sdk库
当前版本
版本1.5.0.87
说明
solidfire python sdk是一个库的集合,它有助于 专有系统与 第三方应用程序。python sdk允许开发人员深入了解 将solidfire系统api与python编程语言集成。这个 solidfire python sdk减少了额外的编码时间 集成所必需的。
兼容性
Component | Version |
---|---|
SolidFire Element OS | 7.0 - 10.0 |
获取帮助
如果您对本产品有任何疑问或意见,请联系 ng-sf-host-integrations-sdk@netapp.com或者上网 位于ThePub的开发人员社区。你的反馈 帮助我们将精力集中在新的特性和功能上。
安装
来自pypi
pip install solidfire-sdk-python
来自源
note:建议使用 virtualenv用于隔离 python环境只提供所需的库。
或者,出于开发目的或检查来源, 以下操作将起作用:
git clone git@github.com:solidfire/solidfire-sdk-python.git cd solidfire-sdk-python git checkout develop pip install -e ".[dev, test, docs, release]" python setup.py install
然后将此目录的位置附加到PYTHONPATH 在其他python脚本中使用sdk的环境变量:
export PYTHONPATH=$PYTHONPATH:/path/to/sf-python-sdk/
就这样-你已经准备好开始和你的SolidFire互动了 使用python集群!
示例
步骤1-使用factory
这是构建 Element 反对。工厂将使用 提供用于测试连接的凭据。它还将设置 基于 sdk和element操作系统。也可以选择设置版本 手动以及是否验证ssl。在 ElementFactory文档。
fromsolidfire.factoryimportElementFactory# Use ElementFactory to get a SolidFireElement object.sfe=ElementFactory.create("ip-address-of-cluster","username","password")
步骤2-调用api方法并检索结果
solidfirelement中的所有服务方法都调用api端点
返回结果对象。命名约定是[method_name]_result
。
例如,list_accounts
返回一个list_accounts_result
对象
它有一个名为accounts
的属性,可以迭代。
此示例发送一个请求以列出帐户,然后提取第一个帐户
从add_account_result
对象。
# Send the request and wait for the result then pull the AccountIDlist_accounts_result=sfe.list_accounts()account=list_accounts_result.accounts[0];
使用python sdk的更多示例
fromsolidfire.factoryimportElementFactory# Create connection to SF Clustersfe=ElementFactory.create("ip-address-of-cluster","username","password")# --------- EXAMPLE 1 - CREATE AN ACCOUNT -----------# Send the request with required parameters and gather the resultadd_account_result=sfe.add_account(username="example-account")# Pull the account ID from the result objectaccount_id=add_account_result.account_id# --------- EXAMPLE 2 - CREATE A VOLUME -------------# Send the request with required parameters and gather the resultcreate_volume_result=sfe.create_volume(name="example-volume",account_id=account_id,total_size=1000000000,enable512e=False)# Pull the VolumeID off the result objectvolume_id=create_volume_result.volume_id# --------- EXAMPLE 3 - LIST ONE VOLUME FOR AN ACCOUNT -------------# Send the request with desired parameters and pull the first volume in the# resultvolume=sfe.list_volumes(accounts=[account_id],limit=1).volumes[0]# pull the iqn from the volumeiqn=volume.iqn# --------- EXAMPLE 3 - MODIFY A VOLUME -------------# Send the request with the desired parameterssfe.modify_volume(volume_id=volume_id,total_size=2000000000)
更多示例
有更多具体的例子here
日志记录
要配置日志记录响应,请执行以下操作:
importloggingfromsolidfireimportcommoncommon.setLogLevel(logging.DEBUG)
要访问元素实例的记录器:
fromsolidfire.commonimportLOG
超时
连接超时(当主机变为 无法到达):
fromsolidfire.factoryimportElementFactorysfe=ElementFactory.create("ip-address-of-cluster","username","password")sfe.timeout(600)
读取超时(用于延长服务调用返回的时间):
fromsolidfire.factoryimportElementFactorysfe=ElementFactory.create("ip-address-of-cluster","username","password")sf.read_timeout(600)
许可证
版权所有©2016,2017 NetApp,Inc.保留所有权利。
根据apache许可证2.0版(以下简称“许可证”)授权;您可以 除非符合许可证,否则不要使用此文件。你可以获得 在
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则软件 根据许可证分发是按“原样”分发的, 无任何明示或默示的保证或条件。 有关管理权限的特定语言和 许可下的限制。