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

Add support for raw IPMI commands #45

Open
korekhov opened this issue Aug 28, 2017 · 2 comments
Open

Add support for raw IPMI commands #45

korekhov opened this issue Aug 28, 2017 · 2 comments

Comments

@korekhov
Copy link
Collaborator

korekhov commented Aug 28, 2017

Something like this, I'd imagine (very simplified version, but even that does not work for me, so looking for your guidance here):


module Rubyipmi::Ipmitool
  class Raw < Rubyipmi::Ipmitool::BaseCommand
    def initialize(opts = ObservableHash.new)
      super("ipmitool", opts)
    end

    def raw_cmd(opt)
      @options["cmdargs"] = "raw #{opt}"
      value = runcmd
      @options.delete_notify("cmdargs")
      if value
        @result
      end
    end

    def test
      raw_cmd("0x00")
    end

  end
end

WIth the following added to lib/rubyipmi/ipmitool/connection.rb

      def raw
        @raw ||= Rubyipmi::Ipmitool::Raw.new(@options)
      end

I get the following output:

# irb
irb(main):001:0> require 'rubyipmi'
=> true
irb(main):002:0> conn = Rubyipmi.connect("root", "root", "<IP>", "ipmitool")
=> #<Rubyipmi::Ipmitool::Connection:0x000000011b2898 @options={"H"=>"<IP>", "U"=>"root", "P"=>"root", "I"=>"lanplus"}>
irb(main):003:0>
irb(main):004:0* conn.raw.test
=> nil
irb(main):005:0>
@korekhov
Copy link
Collaborator Author

korekhov commented Aug 28, 2017

The expected result from above:

# ipmitool -I lanplus -U root -P root -H <IP> raw 0x00
Not enough parameters given.
RAW Commands:  raw <netfn> <cmd> [data]

Network Function Codes:

  VAL	HEX	STRING
==============================================
  0	0x00	Chassis
  2	0x02	Bridge
  4	0x04	SensorEvent
  6	0x06	Application
  8	0x08	Firmware
  10	0x0a	Storage
  12	0x0c	Transport

(can also use raw hex values)

@korekhov
Copy link
Collaborator Author

Never mind - since the exit code of running "raw 0x00" is actually "1", the code works properly as "value" does not get set to true so never returns the output received from BMC.

If change the code to this:

    def raw_cmd(opt)
      @options["cmdargs"] = "raw #{opt}"
      value = runcmd
      @options.delete_notify("cmdargs")
      @result
    end

everything works fine and I get this output:

irb(main):006:0* conn.raw.test
=> "Not enough parameters given.\nRAW Commands:  raw <netfn> <cmd> [data]\n\nNetwork Function Codes:\n\n  VAL\tHEX\tSTRING\n==============================================\n  0\t0x00\tChassis\n  2\t0x02\tBridge\n  4\t0x04\tSensorEvent\n  6\t0x06\tApplication\n  8\t0x08\tFirmware\n  10\t0x0a\tStorage\n  12\t0x0c\tTransport\n\n(can also use raw hex values)\n"
irb(main):007:0>

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

No branches or pull requests

1 participant