redfishtool包和命令行客户端
redfishtool的Python项目详细描述
版权所有2016-2018 DMTF。保留所有权利。
redfishtool
关于
redfish tool是一个命令行工具,它实现了redfish restful api的客户端,用于数据中心硬件管理。
redfish是dmtf可伸缩平台管理论坛(spmf)定义的新restful硬件管理api。它为硬件管理提供了一个现代化、安全、多节点、可扩展的接口。初始版本包括硬件资源清册、服务器电源开/关/复位、读取功耗、设置功率限制、读取风扇等传感器、读取/写入ID LED、资产标签,并且在功能上超越了IPMI,包括处理器、存储、以太网控制器的资源清册,以及埃默里。新的redfish扩展现在已经添加到规范中,包括固件更新、bios配置、内存资源清册、直接连接的存储控制,列表也在增长。
redfishtool使从bash脚本或从客户端命令shell交互使用redfish api变得简单。
当其他通用http客户端(如linux curl)可以发送和接收redfish请求时,redfish工具通过自动处理redfish api中需要cl客户端经常执行对redfish服务的多个查询,以便将超媒体链接从redfish根目录向下遍历到特定资源的详细uri(例如计算机刀片系统中blade-4的processor-2)。具体来说,redfishtool在curl上提供以下函数:
- 实现redfish会话身份验证和http基本身份验证
- 按照严格的互操作性处理器…]遍历redfish模式,以根据id、uuid、url或其他属性查找目标实例
- 处理以多个片段返回的集合的获取—要求客户端在循环中读取,直到返回完整集合为止
- 在修补资源以写入属性时处理ETag和if-match头
- 使用简单的命令行语法实现许多常见的设置或操作操作(例如服务器重置、设置LED、assettag、powerlimits等)
- 在客户端和服务之间协商最新的redfish协议版本(演示正确的方法)
- 可以读取资源的特定属性,或展开集合以包含展开的集合的所有成员
- 支持添加和删除用户以及常见的redfish帐户服务操作
- 对于debug,提供多个级别的详细输出以添加描述性头,并显示正在执行的http请求
- 对于调试,包括多级状态显示,显示返回和发送的http状态代码和标题
- 为了便于分析,以json格式输出所有响应,除非指定了详细或状态调试选项
为什么是redfishtool?
- redfish工具最初是在开发redfish规范的过程中编写的,目的是帮助查找规范中的歧义。
- redfishtool现在也用于测试redfish服务实现之间的互操作性。
- 此外,redfishtool提供了一个示例实现,说明客户机如何执行常见的服务器管理功能,如资源清册、电源开/关/重置、设置电源限制、指示灯和资产设置,以及搜索多节点redfish服务以查找SPEcific节点(具有特定的uuid、redfish id等)。redfishtool遵循严格的互操作性规则。为了支持这一目标,在代码中添加了大量注释来解释执行每个步骤的原因。
- 如上所述,它使得从bash脚本中使用redfish api变得容易,or是一个易于使用的交互式cli——但不需要创建一个"新api"。redfishtool的所有(相当大部分)响应都是redfish定义的响应。属性和资源在redfish规范中定义。redfish工具只是访问redfish api的工具,而不是新接口本身。
- 执行选项是为所有集合添加"list"操作,以显示每个成员的键属性,而不仅仅是成员的uri。
< > > - 请求-https://github.com/kennethreitz/requests" rel="nofollow">https://github.com/kennethreitz/requests
- redfishtool是一个python3.4+程序。它使用python3"requests"lib发送http请求,并使用python3.4+ 中的许多其他标准lib
- redfishtool选项/optarg解析严格遵循已建立的linux/gnu getopt语法,其中参数和选项可以按任意顺序指定,并且支持短(例如-r<;host>;)或长(--rhost=<;host>;)语法。
- 选项用于传递用户名、密码、主机:端口、身份验证选项、详细/状态标志,还用于指定如何搜索以查找特定集合成员(-i<;id>;、-a(all)、-m<;prop>;:<;val>;)。
- 子命令指示api的一般区域(遵循ipmitool约定),并与redfish导航属性名(如"chassis"、"systems"、"accountservice"等)对齐。
- 操作指定要执行的操作或操作,如s
s ystems setbootoverride
..或systems reset
- 其他参数是操作后有时需要的任何其他参数,例如:
系统<;setbootoverride>;<;启用值>;
<;targetvalue>;` - 修改以使修补程序命令更好地用于windows cmd shell引用
- 支持clearlog
- 添加在1.0之后添加到Redfish的其他API—此版本仅支持1.0 API
- 添加自定义角色创建和删除 < > >
安装
redfishtool
可以通过pip安装
pip install redfishtool
要求
redfishtool基于python 3,客户端系统需要安装python框架,然后才能在系统上安装和执行该工具。
如果从github克隆工具,而不是通过pip执行安装,则需要安装以下软件包并从python环境访问它们:
您可以通过运行以下命令安装所需的软件包:
pip install -r requirements.txt
用法
pythonredfishtool[选项[子命令[操作[其他参数
常用选项:
-V, --version -- show redfishtool version, and exit
-h, --help -- show Usage, Options, and list of subCommands, and exit
-v, --verbose -- verbose level, can repeat up to 5 times for more verbose output
-v(header), -vv(+addl info), -vvv(Request trace), -vvvv(+subCmd dbg), -vvvvv(max dbg)
-s, --status -- status level, can repeat up to 5 times for more status output
-s(http_status),
-ss(+r.url, +r.elapsed executionTime ),
-sss(+request hdrs,data,authType, +response status_code, +response executionTime,
+login auth token/sessId/sessUri)
-ssss(+response headers), -sssss(+response data
-u <user>, --user=<usernm> -- username used for remote redfish authentication
-p <passwd>, --password=<passwd> -- password used for remote redfish authentication
-r <rhost>, --rhost=<rhost> -- remote redfish service hostname or IP:port
-t <token>, --token=<token> -- redfish auth session token-for sessions across multiple calls
-q, --quiet -- quiet mode--suppress error, warning, and diagnostic messages
-c <cfgFile>,--config=<cfgFile> -- read options (including credentials) from file <cfgFile>
-T <timeout>,--Timeout=<timeout> -- timeout in seconds for each http request. Default=10
-P <property>, --Prop=<property> -- return only the specified property. Applies only to all "get" operations
-E, --Entries -- Fetch the Logs entries. Applies to Logs sub-command of Systems, Chassis and Managers
由"raw"子命令使用的选项:
-d <data> --data=<data> -- the http request "data" to send on PATCH,POST,or PUT requests
指定顶级集合成员的选项:例如:系统-i<;sysid>;
对于需要指定顶级集合成员的系统
、管理器
和机箱
命令,如果未指定任何选项,则默认值为--one
-I <Id>, --Id=<Id> -- Use <Id> to specify the collection member
-M <prop>:<val> --Match=<prop>:<val>-- Use <prop>=<val> search to find the collection member
-F, --First -- Use the 1st link returned in the collection or 1st "matching" link if used with -M
-1, --One -- Use the single link returned in the collection. Return error if more than one member exists
-a, --all -- Returns all members if the operation is a Get on a top-level collection like Systems
-L <Link>, --Link=<Link> -- Use <Link> (eg /redfish/v1/Systems/1) to reference the collection member.
-- If <Link> is not one of the links in the collection, and error is returned.
指定二级集合成员的选项:例如:系统-i<;sysid>;处理器-i<;procid>;
-i <id>, --id=<id> -- use <id> to specify the 2nd-level collection member
-m <prop>:<val> --match=<prop>:val>--use <prop>=<val> search of 2nd-level collection to specify member
-l <link> --link=<link> -- Use <link> (eg /redfish/v1/SYstems/1/Processors/1) to reference a 2nd level resource
-- A -I|M|F|1|L option is still required to specify the link to the top-lvl collection
-a, --all -- Returns all members of the 2nd level collection if the operation is a Get on the
-- 2nd level collection (eg Processors). -I|M|F|1|L still specifies the top-lvl collection.
其他选项:
-W <num>:<connTimeout>, -- Send up to <num> {GET /redfish} requests with <connTimeout> TCP connection timeout
--Wait=<num>:<ConnTimeout> -- before sending subcommand to rhost. Default is -W 1:3
-A <Authn>, --Auth <Authn> -- Authentication type to use: Authn={None|Basic|Session} Default is Basic
-S <Secure>, --Secure=<Secure> -- When to use https: (Note: doesn't stop rhost from redirect http to https)
<Secure>={Always | IfSendingCredentials | IfLoginOrAuthenticatedApi(default) }
-R <ver>, --RedfishVersion=<ver>-- The Major Redfish Protocol version to use: ver={v1(dflt), v<n>, Latest}
-C --CheckRedfishVersion -- tells Redfishtool to execute GET /redfish to verify that the rhost supports
the specified redfish protocol version before executing a sub-command.
The -C flag is auto-set if the -R Latest or -W ... options are selected
-H <hdrs>, --Headers=<hdrs> -- Specify the request header list--overrides defaults. Format "{ A:B, C:D...}"
-D <flag>, --Debug=<flag> -- Flag for dev debug. <flag> is a 32-bit uint: 0x<hex> or <dec> format
子命令:
hello -- redfishtool hello world subcommand for dev testing
about -- display version and other information about this version of redfishtool
versions -- get redfishProtocol versions supported by rhost: GET ^/redfish
root | serviceRoot -- get serviceRoot resouce: GET ^/redfish/v1/
Systems -- operations on Computer Systems in the /Systems collection
Chassis -- operations on Chassis in the /Chassis collection
Managers -- operations on Managers in the /Managers collection
AccountService -- operations on AccountService including user administration
SessionService -- operations on SessionService including Session login/logout
odata -- get the Odata Service document: GET ^/redfish/v1/odata
metadata -- get the CSDL metadata document: GET ^/redfish/v1/$metadata
raw -- subcommand to execute raw http methods(GET,PATCH,POST...) and URIs
对于子命令的使用,包括子命令操作和其他参数,请执行:
redfishtool <SubCommand> -h -- usage and options for specific subCommand
子命令操作和addl args
系统操作
pip install redfishtool
0
底盘操作
pip install redfishtool
1
经理运营部
pip install redfishtool
2
会计服务操作
pip install redfishtool
3
会话服务操作
pip install redfishtool
4
原始操作
pip install redfishtool
5
示例用法
系统子命令示例
pip install redfishtool
6
机箱子命令示例
αα-α17
managers子命令示例
pip install redfishtool
8
accountservice子命令示例
pip install redfishtool
9
sessionservice子命令示例
pip install -r requirements.txt
0
在Windows中运行
pip install redfishtool
pip install redfishtool
1
经理运营部
pip install redfishtool
2
会计服务操作
pip install redfishtool
3
会话服务操作
pip install redfishtool
4
原始操作
pip install redfishtool
5
示例用法
系统子命令示例
pip install redfishtool
6
机箱子命令示例
αα-α17
managers子命令示例
pip install redfishtool
8
accountservice子命令示例
pip install redfishtool
9
sessionservice子命令示例
pip install -r requirements.txt
0
在Windows中运行
pip install redfishtool
pip install redfishtool
3
会话服务操作
pip install redfishtool
4
原始操作
pip install redfishtool
5
示例用法
系统子命令示例
pip install redfishtool
6
机箱子命令示例
αα-α17
managers子命令示例
pip install redfishtool
8
accountservice子命令示例
pip install redfishtool
9
sessionservice子命令示例
pip install -r requirements.txt
0
在Windows中运行
pip install redfishtool
pip install redfishtool
pip install redfishtool
pip install redfishtool
pip install redfishtool
pip install -r requirements.txt
要使可执行文件在使用Windows时解析,请确保PATH环境变量中同时包含"python"和"scripts"文件夹。例如,如果将python安装到"c:\ python",则path环境变量应包括"c:\ python"和"c:\ python\scripts"。