Sha256: aacfb106ee7251e54b54ac94ed87506916d74e179dbb68b72ec6187681ddf610

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

module Rubyipmi::Freeipmi
  class Power < Rubyipmi::Freeipmi::BaseCommand

    def initialize(opts = ObservableHash.new)
      super("ipmipower", opts)
    end

    # The command function is a wrapper that actually calls the run method
    def command(opt)
      @options[opt] = false
      value = runcmd
      @options.delete_notify(opt)
      return @result
    end

    # Turn on the system
    def on
      command("on")
    end

    # Turn off the system
    def off
      command("off")
    end

    # Power cycle the system
    def cycle
      # if the system is off turn it on
      if off?
        on
      else
        command("cycle")
      end

    end

    # Perform a power reset on the system
    def reset
      command("reset")
    end

    # Perform a soft shutdown, like briefly pushing the power button
    def softShutdown
      command("soft")
    end

    def powerInterrupt
      command("pulse")
    end

    # Get the power status of the system, will show either on or off
    def status
      value = command("stat")
      if value
        @result.split(":").last.chomp.strip
      end
    end

    # Test to see if the power is on
    def on?
      status == "on"
    end

    # Test to see if the power is off
    def off?
      status == "off"
    end



  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubyipmi-0.10.0 lib/rubyipmi/freeipmi/commands/power.rb
rubyipmi-0.9.3 lib/rubyipmi/freeipmi/commands/power.rb
rubyipmi-0.9.2 lib/rubyipmi/freeipmi/commands/power.rb
rubyipmi-0.9.1 lib/rubyipmi/freeipmi/commands/power.rb
rubyipmi-0.9.0 lib/rubyipmi/freeipmi/commands/power.rb
rubyipmi-0.8.1 lib/rubyipmi/freeipmi/commands/power.rb
rubyipmi-0.7.0 lib/rubyipmi/freeipmi/commands/power.rb