Class: CollinsShell::Ipmi

Inherits:
Thor
  • Object
show all
Includes:
ThorHelper, Util
Defined in:
lib/collins_shell/ipmi.rb

Constant Summary

Constants included from Util

Util::SIZABLE_ATTRIBUTES

Constants included from ThorHelper

ThorHelper::COLLINS_OPTIONS, ThorHelper::PAGE_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#asset_exec, #asset_get, #call_collins, #finalize_exec, #format_asset_tags, #format_asset_value, #get_selector, #is_array?, #print_find_results, #run_command_in_thread, #say_status, #thread_mgr

Methods included from ThorHelper

#appropriate_answer?, #batch_selector_operation, #collins_config_from_file, #ensure_password, #get_collins_client, #get_collins_config, #get_password, included, #require_valid_collins_config, #require_yes, #say_error, #say_success, #selector_or_tag, #try_config_merge, #use_collins_options, #use_nuke_option, #use_page_options, #use_selector_option, #use_tag_option

Class Method Details



12
13
14
# File 'lib/collins_shell/ipmi.rb', line 12

def self.banner task, namespace = true, subcommand = false
  "#{basename} #{task.formatted_usage(self, true, subcommand).gsub(':',' ')}"
end

.ipmi_options(required = false) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/collins_shell/ipmi.rb', line 16

def self.ipmi_options required = false
  method_option :ipmi_username, :type => :string, :required => required, :desc => 'IPMI username'
  method_option :ipmi_password, :type => :string, :required => required, :desc => 'IPMI password'
  method_option :address, :type => :string, :required => required, :desc => 'IPMI address'
  method_option :gateway, :type => :string, :required => required, :desc => 'IPMI gateway'
  method_option :netmask, :type => :string, :required => required, :desc => 'IPMI netmask'
end


24
25
26
27
# File 'lib/collins_shell/ipmi.rb', line 24

def self.print_ipmi ipmi
  puts("address,gateway,netmask,username,password")
  puts([ipmi.address,ipmi.gateway,ipmi.netmask,ipmi.username,ipmi.password].join(','))
end

Instance Method Details

#createObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/collins_shell/ipmi.rb', line 49

def create
  call_collins get_collins_client, "create ipmi" do |client|
    ipmi = client.ipmi_create options.tag, options.ipmi_username, options.ipmi_password, options.address, options.gateway, options.netmask
    if ipmi then
      asset = client.get options.tag
      CollinsShell::Ipmi.print_ipmi asset.ipmi
    else
      say_error "create IPMI address"
    end
  end
end

#generateObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/collins_shell/ipmi.rb', line 33

def generate
  call_collins get_collins_client, "generate ipmi" do |client|
    ipmi = client.ipmi_allocate options.tag, :pool => options.pool
    if ipmi then
      asset = client.get options.tag
      CollinsShell::Ipmi.print_ipmi asset.ipmi
    else
      say_error "generate IPMI address"
    end
  end
end

#poolsObject



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/collins_shell/ipmi.rb', line 83

def pools
  call_collins get_collins_client, "ipmi pools" do |client|
    # NAME, NETWORK, START_ADDRESS, SPECIFIED_GATEWAY, GATEWAY, BROADCAST, POSSIBLE_ADDRESSES
    header = [["Pool","Network","Gateway","Broadcast","Possible Addresses","Start Address","Specified Gateway"]]
    rows = client.ipmi_pools.map do |pool|
      [pool["NAME"], pool["NETWORK"], pool["GATEWAY"], pool["BROADCAST"], pool["POSSIBLE_ADDRESSES"],
        pool["START_ADDRESS"], pool["SPECIFIED_GATEWAY"]]
    end
    print_table header + rows
  end
end

#updateObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/collins_shell/ipmi.rb', line 65

def update
  call_collins get_collins_client, "update ipmi" do |client|
    ipmi = client.ipmi_update options.tag, :username => options.ipmi_username,
                                           :password => options.ipmi_password,
                                           :address => options.address,
                                           :gateway => options.gateway,
                                           :netmask => options.netmask
    if ipmi then
      asset = client.get options.tag
      CollinsShell::Ipmi.print_ipmi asset.ipmi
    else
      say_error "update IPMI address"
    end
  end
end