Skip to content
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

Merged
merged 1 commit into from May 5, 2017
Merged

Fixes #2595 - Add more Rubyipmi methods to BMC API #521

merged 1 commit into from May 5, 2017

Conversation

Deltik
Copy link
Contributor

@Deltik Deltik commented Apr 20, 2017

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 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

@dmitri-d
Copy link
Member

[test]

def frulist
frulist = host.fru.list
# Detect quirk on ipmitool
raise 'Quirk' if frulist.empty?
Copy link
Member

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?

Copy link
Contributor Author

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.

# 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
Copy link
Member

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?

Copy link
Contributor Author

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.

raise 'Quirk' if frulist.empty?
frulist
rescue Exception => e
msg = "Unknown error getting fru list."
Copy link
Member

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?

Copy link
Contributor Author

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

end
# Handle ipmitool
return "#{msg} Try bmc_provider=freeipmi for possible quirk workaround." if e.message == 'Quirk'
return msg
Copy link
Member

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.

Copy link
Contributor Author

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
@dmitri-d
Copy link
Member

dmitri-d commented May 5, 2017

[test]

@dmitri-d
Copy link
Member

dmitri-d commented May 5, 2017

Looks good, waiting for the results of the build.

@dmitri-d dmitri-d merged commit a9332b6 into theforeman:develop May 5, 2017
@dmitri-d
Copy link
Member

dmitri-d commented May 5, 2017

Merged, thanks @Deltik.

@dmitri-d
Copy link
Member

dmitri-d commented May 5, 2017

@Deltik: did you have anything in mind re: changes to Foreman UI?

@Deltik
Copy link
Contributor Author

Deltik commented May 5, 2017

@witlessbird: Foreman could use this additional functionality as part of

Foreman » Hosts » All hosts » (any host with a BMC) » BMC

Foreman hosts BMC info

Currently, when showing any host with a BMC, Foreman makes these requests in the background to the associated Smart Proxy:

  • GET /bmc/BMC_IP_ADDRESS/chassis/power/status HTTP/1.1
  • GET /bmc/BMC_IP_ADDRESS/lan/ip HTTP/1.1
  • GET /bmc/BMC_IP_ADDRESS/lan/netmask HTTP/1.1
  • GET /bmc/BMC_IP_ADDRESS/lan/mac HTTP/1.1
  • GET /bmc/BMC_IP_ADDRESS/lan/gateway HTTP/1.1

, where BMC_IP_ADDRESS is the IP address of the BMC.

I'm thinking there could be buttons added to fetch additional information from BMC that take longer than a few seconds, such as GET /bmc/BMC_IP_ADDRESS/fru/list, which takes 15 seconds for me using ipmitool and 2 seconds for me using freeipmi.

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:

Foreman host power actions

Currently, "Cycle" means the same thing as "Reset" because they both call PUT /bmc/BMC_IP_ADDRESS/chassis/power/cycle, but now, "Reset" can be changed to mean /bmc/BMC_IP_ADDRESS/chassis/power/reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants