class HmcLpar

class is taking all data from HMC (only), is able to compare running options with data in profiles

Attributes

errors[R]
hmc[RW]
lpar_id[RW]
lpar_name[RW]
name[RW]
profiles[R]
sys[RW]
verbose[RW]
vioses[RW]
warnings[R]

Public Class Methods

new(sys = nil, lpar_id = nil, name = nil, hmc = nil) click to toggle source
Calls superclass method Lpar_real::new
# File lib/Framework/HmcLpar.rb, line 23
def initialize(sys = nil, lpar_id = nil, name = nil, hmc = nil)
  super(sys, lpar_id, name)
  @hmc = hmc
  @sys = sys
  @lpar_id = lpar_id
  @name = name
  @profiles = {}
  @vioses = {}


  @errors   = []
  @warnings = []

  @verbose = 0
end

Public Instance Methods

current_profile_vs_running() click to toggle source
# File lib/Framework/HmcLpar.rb, line 87
def current_profile_vs_running
  unless parsed_all?
    print 'Not all needed data are provided'
    pp @_parsed
    return false
  end

  # let's compare CPU and memory

  # let's compare virtual slots
  @profiles.each_pair { |name, profile|
    pp profile.to_s
  }

    # curr_pend = {
    #     'curr_min_mem' => 'pend_min_mem',
    #     'curr_mem' => 'pend_mem',
    #     'curr_max_mem' => 'pend_max_mem',
    #     'curr_min_num_huge_pages' => 'pend_min_num_huge_pages',
    #     'curr_num_huge_pages' => 'pend_num_huge_pages',
    #     'curr_max_num_huge_pages' => 'pend_max_num_huge_pages',
    #     'curr_proc_mode' => 'pend_proc_mode',
    #     'curr_min_procs' => 'pend_min_procs',
    #     'curr_procs' => 'pend_procs',
    #     'curr_max_procs' => 'pend_max_procs',
    #     'curr_sharing_mode' => 'pend_sharing_mode',
    #     'curr_min_proc_units' => 'pend_min_proc_units',
    #     'curr_proc_units' => 'pend_proc_units',
    #     'curr_max_proc_units' => 'pend_max_proc_units',
    #     'curr_uncap_weight' => 'pend_uncap_weight',
    #     'curr_shared_proc_pool_id' => 'pend_shared_proc_pool_id',
    #     'curr_max_virtual_slots' => 'pend_max_virtual_slots',
    # }

end
hashToLpar(hash) click to toggle source
# File lib/Framework/HmcLpar.rb, line 59
def hashToLpar(hash)

  hash['prof'].split("\n").each { |line|
    profile_add(line)
  }

  lssyscfg_decode(hash['lpar_info']) unless hash['lpar_info'].nil?
  decode_mem(hash['memory']) unless hash['memory'].nil?
  decode_proc(hash['proc']) unless hash['proc'].nil?
  decodeVirtualioSlot(hash['virtual_slot']) unless  hash['virtual_slot'].nil?
  decode_virtualio_eth(hash['virtual_eth']) unless  hash['virtual_eth'].nil?
  decode_virtual_serial(hash['virtual_serial']) unless  hash['virtual_serial'].nil?
  decode_virtual_scsi(hash['virtual_scsi']) unless  hash['virtual_scsi'].nil?
end
profile_add(profile) click to toggle source
# File lib/Framework/HmcLpar.rb, line 39
def profile_add(profile)
  if profile.class.to_s == 'String'
    profile_tmp = Lpar_profile.new
    profile_tmp.parse(profile)
    profile = profile_tmp
  end

  raise 'profile to add is not proper profile object or string with profile' unless profile.class.to_s == 'Lpar_profile'

  @profiles[profile.name]= profile
end
profile_delete(profile_name) click to toggle source
# File lib/Framework/HmcLpar.rb, line 51
def profile_delete(profile_name)
  @profiles.delete(profile_name)
end
profile_exist?(profile_name) click to toggle source
# File lib/Framework/HmcLpar.rb, line 55
def profile_exist?(profile_name)
  @profiles.include?(profile_name)
end
running_vs_pending() click to toggle source
# File lib/Framework/HmcLpar.rb, line 74
def running_vs_pending
  curr_pend_array = %w[ min_mem mem nax_mem min_num_huge_pages num_huge_pages
                       max_num_huge_pages proc_mode min_procs procs max_procs sharing_mode min_proc_units proc_units
                       max_proc_units uncap_weight shared_proc_pool_id max_virtual_slots
                      ]

  curr_pend_array.each { |name|
    if instance_variable_get("@curr_#{name}") != instance_variable_get("@pend_#{name}")
      @errors.push("curr_#{name}:" + instance_variable_get("@curr_#{name}") +  "  vs pend_#{name}:" + instance_variable_get("@pend_#{name}") )
    end
  }
end