Class: HmcLpar

Inherits:
Lpar_real show all
Defined in:
lib/Framework/HmcLpar.rb

Overview

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

Direct Known Subclasses

Lpar

Instance Attribute Summary collapse

Attributes inherited from Lpar_real

#_parsed, #adaptersReal, #adaptersVirtual, #affinity_group_id, #allow_perf_collection, #auto_start, #boot_mode, #curr_hpt_ratio, #curr_lpar_proc_compat_mode, #curr_max_mem, #curr_max_num_huge_pages, #curr_max_proc_units, #curr_max_procs, #curr_max_virtual_slots, #curr_mem, #curr_min_mem, #curr_min_num_huge_pages, #curr_min_proc_units, #curr_min_procs, #curr_num_huge_pages, #curr_proc_mode, #curr_proc_units, #curr_procs, #curr_profile, #curr_shared_proc_pool_id, #curr_sharing_mode, #curr_uncap_weight, #default_profile, #desired_lpar_proc_compat_mode, #logical_serial_num, #lpar_avail_priority, #lpar_env, #lpar_keylock, #mem_mode, #msp, #next_avail_virtual_slot, #os_version, #pend_max_mem, #pend_max_num_huge_pages, #pend_max_proc_units, #pend_max_procs, #pend_max_virtual_slots, #pend_mem, #pend_min_mem, #pend_min_num_huge_pages, #pend_min_proc_units, #pend_min_procs, #pend_num_huge_pages, #pend_proc_mode, #pend_proc_units, #pend_procs, #pend_shared_proc_pool_id, #pend_sharing_mode, #pend_uncap_weight, #power_ctrl_lpar_ids, #powervm_mgmt_capable, #redundant_err_path_reporting, #remote_restart_capable, #remote_restart_status, #resource_config, #rmc_ipaddr, #rmc_state, #run_mem, #run_min_mem, #run_num_huge_pages, #run_proc_units, #run_procs, #run_uncap_weight, #shared_proc_pool_util_auth, #simplified_remote_restart_capable, #state, #suspend_capable, #sync_curr_profile, #time_ref, #type_model, #virtual_scsi_adapters, #vtpm_enabled, #work_group_id

Instance Method Summary collapse

Methods inherited from Lpar_real

#decodeVirtualioSlot, #decode_mem, #decode_proc, #decode_virtual_scsi, #decode_virtual_serial, #decode_virtualio_eth, #lpar_remove_cmd, #lssyscfg_decode, #memory_add_cmd, #memory_remove_cmd, #memory_restore_to_profile_cmd, #parsed_all?, #proc_units_add_cmd, #proc_units_remove_cmd, #slot_remove_cmd, #start_cmd, #status_cmd, #stop_cmd, #virtual_adapter_eth_add, #virtual_adapter_exist?, #virtual_adapter_first_free, #virtual_adapter_remove, #virtual_adapter_scsi_add

Constructor Details

#initialize(sys = nil, lpar_id = nil, name = nil, hmc = nil) ⇒ HmcLpar

Returns a new instance of HmcLpar.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



13
14
15
# File 'lib/Framework/HmcLpar.rb', line 13

def errors
  @errors
end

#hmcObject

Returns the value of attribute hmc.



10
11
12
# File 'lib/Framework/HmcLpar.rb', line 10

def hmc
  @hmc
end

#lpar_idObject

Returns the value of attribute lpar_id.



11
12
13
# File 'lib/Framework/HmcLpar.rb', line 11

def lpar_id
  @lpar_id
end

#lpar_nameObject

Returns the value of attribute lpar_name.



9
10
11
# File 'lib/Framework/HmcLpar.rb', line 9

def lpar_name
  @lpar_name
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/Framework/HmcLpar.rb', line 8

def name
  @name
end

#profilesObject (readonly)

Returns the value of attribute profiles.



19
20
21
# File 'lib/Framework/HmcLpar.rb', line 19

def profiles
  @profiles
end

#sysObject

Returns the value of attribute sys.



7
8
9
# File 'lib/Framework/HmcLpar.rb', line 7

def sys
  @sys
end

#verboseObject

Returns the value of attribute verbose.



15
16
17
# File 'lib/Framework/HmcLpar.rb', line 15

def verbose
  @verbose
end

#viosesObject

Returns the value of attribute vioses.



17
18
19
# File 'lib/Framework/HmcLpar.rb', line 17

def vioses
  @vioses
end

#warningsObject (readonly)

Returns the value of attribute warnings.



14
15
16
# File 'lib/Framework/HmcLpar.rb', line 14

def warnings
  @warnings
end

Instance Method Details

#current_profile_vs_runningObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# 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) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# 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) ⇒ Object



51
52
53
# File 'lib/Framework/HmcLpar.rb', line 51

def profile_delete(profile_name)
  @profiles.delete(profile_name)
end

#profile_exist?(profile_name) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/Framework/HmcLpar.rb', line 55

def profile_exist?(profile_name)
  @profiles.include?(profile_name)
end

#running_vs_pendingObject



74
75
76
77
78
79
80
81
82
83
84
85
# 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