New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2595 - Add more Rubyipmi methods to BMC API #521
Fixes #2595 - Add more Rubyipmi methods to BMC API #521
Conversation
[test] |
modules/bmc/ipmi.rb
Outdated
def frulist | ||
frulist = host.fru.list | ||
# Detect quirk on ipmitool | ||
raise 'Quirk' if frulist.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this hard to read/follow. Can 'quirk' happen with ipmitool only? If so, why not return the error message on line 218 right away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed in 7fbe331.
modules/bmc/ipmi.rb
Outdated
# returns "invalid byte sequence in UTF-8". The second time does a | ||
# successful fru list. | ||
return host.fru.list if host.is_a? Rubyipmi::Freeipmi::Connection | ||
rescue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call above can throw RuntimeErrors only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm catching all exceptions and feeding their messages through to the client.
modules/bmc/ipmi.rb
Outdated
raise 'Quirk' if frulist.empty? | ||
frulist | ||
rescue Exception => e | ||
msg = "Unknown error getting fru list." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the case? Wouldn't exception contain the details of the error that caused it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed in 7fbe331. Exceptions are now returned as
Error getting fru list:
Exception#message
modules/bmc/ipmi.rb
Outdated
end | ||
# Handle ipmitool | ||
return "#{msg} Try bmc_provider=freeipmi for possible quirk workaround." if e.message == 'Quirk' | ||
return msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also hard to follow. I'd suggest returning an error message at the top of the rescue block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed in 7fbe331.
Replaces: #505 Replaces: 051b285 This commit implements the same features as 051b285, with some differences: - Added unit tests for all new features - Added interfaces to `modules/bmc/base.rb` - Cleared up some ambiguous method names - Changed some unit test stubs to expects - Fixed bugs in the original implementation New API methods: - GET /bmc/:host/fru Shows available actions: "list", "serial", "manufacturer", "model", and "asset_tag" - GET /bmc/:host/bmc Shows available actions: "info", "guid", and "version" - GET /bmc/:host/sensors Shows available actions: "list", "count", "names", "fanlist", "templist", and "get" - GET /bmc/:host/lan/snmp Shows BMC host's SNMP community string - GET /bmc/:host/lan/vlanid Shows BMC host's VLAN ID - GET /bmc/:host/lan/ipsrc Shows whether BMC host's LAN was configured "static" or "dhcp" - GET /bmc/:host/lan/print Shows BMC hosts's LAN configuration - PUT /bmc/:host/chassis/power/reset Performs power reset on chassis - GET /bmc/:host/fru/list Shows all of host's FRU information. Includes workaround for undocumented IBM/Lenovo IPMI bug. - GET /bmc/:host/fru/serial Shows host's serial number - GET /bmc/:host/fru/manufacturer Shows host's manufacturer - GET /bmc/:host/fru/model Shows host's product model - GET /bmc/:host/fru/asset_tag Shows host's asset tag string, if Rubyipmi has this method. It's in the spec, but doesn't seem to be implemented today. See logicminds/rubyipmi/blob/master/spec/unit/ipmitool/fru_spec.rb - GET /bmc/:host/bmc/info Shows information about the BMC - GET /bmc/:host/bmc/guid Shows system's GUID - GET /bmc/:host/version Shows BMC's version - PUT /bmc/:host/bmc/reset?type=warm Performs warm reset on BMC - PUT /bmc/:host/bmc/reset?type=cold Performs cold reset on BMC - GET /bmc/:host/sensors/list Shows all of host's sensors - GET /bmc/:host/sensors/count Shows number of sensors on host - GET /bmc/:host/sensors/names Shows list of sensor names on host - GET /bmc/:host/sensors/fanlist Shows all of host's fan sensors - GET /bmc/:host/sensors/templist Shows all of host's temperature sensors - GET /bmc/:host/sensors/get Shows available option "sensor" for this action - GET /bmc/:host/sensors/get/:sensor Shows information about sensor :sensor on host
[test] |
Looks good, waiting for the results of the build. |
Merged, thanks @Deltik. |
@Deltik: did you have anything in mind re: changes to Foreman UI? |
@witlessbird: Foreman could use this additional functionality as part of
Currently, when showing any host with a BMC, Foreman makes these requests in the background to the associated Smart Proxy:
, where I'm thinking there could be buttons added to fetch additional information from BMC that take longer than a few seconds, such as There could also be a button to fetch sensor information. And a button to perform a BMC reset. I haven't thought this through much, but Foreman can use these new API methods for additional BMC functionality. We can also fix an issue with this: Currently, "Cycle" means the same thing as "Reset" because they both call |
Replaces: #505
Replaces: 051b285
This commit implements the same features as
051b285, with some differences:
modules/bmc/base.rb
New API methods:
GET /bmc/:host/fru
Shows available actions: "list", "serial", "manufacturer", "model",
and "asset_tag"
GET /bmc/:host/bmc
Shows available actions: "info", "guid", and "version"
GET /bmc/:host/sensors
Shows available actions: "list", "count", "names", "fanlist",
"templist", and "get"
GET /bmc/:host/lan/snmp
Shows BMC host's SNMP community string
GET /bmc/:host/lan/vlanid
Shows BMC host's VLAN ID
GET /bmc/:host/lan/ipsrc
Shows whether BMC host's LAN was configured "static" or "dhcp"
GET /bmc/:host/lan/print
Shows BMC hosts's LAN configuration
PUT /bmc/:host/chassis/power/reset
Performs power reset on chassis
GET /bmc/:host/fru/list
Shows all of host's FRU information. Includes workaround for
undocumented IBM/Lenovo IPMI bug.
GET /bmc/:host/fru/serial
Shows host's serial number
GET /bmc/:host/fru/manufacturer
Shows host's manufacturer
GET /bmc/:host/fru/model
Shows host's product model
GET /bmc/:host/fru/asset_tag
Shows host's asset tag string, if Rubyipmi has this method. It's in
the spec, but doesn't seem to be implemented today. See spec here.
GET /bmc/:host/bmc/info
Shows information about the BMC
GET /bmc/:host/bmc/guid
Shows system's GUID
GET /bmc/:host/version
Shows BMC's version
PUT /bmc/:host/bmc/reset?type=warm
Performs warm reset on BMC
PUT /bmc/:host/bmc/reset?type=cold
Performs cold reset on BMC
GET /bmc/:host/sensors/list
Shows all of host's sensors
GET /bmc/:host/sensors/count
Shows number of sensors on host
GET /bmc/:host/sensors/names
Shows list of sensor names on host
GET /bmc/:host/sensors/fanlist
Shows all of host's fan sensors
GET /bmc/:host/sensors/templist
Shows all of host's temperature sensors
GET /bmc/:host/sensors/get
Shows available option "sensor" for this action
GET /bmc/:host/sensors/get/:sensor
Shows information about sensor :sensor on host