Skip to content

Commit

Permalink
Added support to get stealable resources from Not Activated lpars
Browse files Browse the repository at this point in the history
CPU:Added support to get the procs assigned to not activated lpars
and adding them to the max_procs of the target lpar along with
the proc available from the CEC

Memory:Added support to get the memory assigned to not activated
lpars and adding them to the max_memory of the target lpar
along with memory available from the CEC

Signed-off-by: Shirisha G <[email protected]>
  • Loading branch information
shirishaganta1 committed Jun 3, 2024
1 parent 76e0d7e commit 39793c2
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 9 deletions.
68 changes: 65 additions & 3 deletions common/OpTestHMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ def change_proc_mode(self, proc_mode, sharing_mode, min_proc_units, desired_proc
self.set_lpar_cfg("proc_mode=shared,sharing_mode=%s,min_proc_units=%s,max_proc_units=%s,"
"desired_proc_units=%s,min_procs=%s,desired_procs=%s,max_procs=%s,"
"min_mem=%s,desired_mem=%s,max_mem=%s" %
(sharing_mode, min_proc_units, max_proc_units, desired_proc_units,
overcommit_ratio*int(min_proc_units), overcommit_ratio*int(desired_proc_units),
3*int(max_proc_units),min_memory, desired_memory, max_memory))
(sharing_mode, overcommit_ratio*int(min_proc_units), max_proc_units, overcommit_ratio*int(desired_proc_units),
int(min_proc_units), 2*int(desired_proc_units),
2*int(max_proc_units),min_memory, desired_memory, max_memory))
elif proc_mode == 'ded':
self.set_lpar_cfg("proc_mode=ded,sharing_mode=%s,min_procs=%s,max_procs=%s,desired_procs=%s,"
"min_mem=%s,desired_mem=%s,max_mem=%s" %
Expand Down Expand Up @@ -599,6 +599,68 @@ def get_available_proc_resources(self):
return self.run_command("lshwres -m %s -r proc --level sys -F curr_avail_sys_proc_units" %
self.mg_system)

def get_stealable_resources(self):
'''
we are getting the not activated lpars
list in order to steal the procs and mem resources
'''
output = self.run_command(
"lssyscfg -r lpar -m %s -F name state" % self.mg_system)
# Split the output into lines
# lines = output.splitlines()
# Initialize an empty list to store the first column values
not_activated_lpars = []
# Iterate over each line to extract the first column value if the state is "Not Activated"
for line in output:
# Split the line using space as the delimiter
parts = line.split()
# Check if the state is "Not Activated" and extract the first column value
if len(parts) >= 2 and parts[1] == '"Not':
lpar_name = parts[0]
# Append the LPAR name to the list
not_activated_lpars.append(lpar_name)
return not_activated_lpars

def get_stealable_proc_resources_lpar(self):
'''
we are getting the procs assigned to not activated lpars
'''
stealable_procs = []
lpars = self.get_stealable_resources()
for lpar in lpars:

lpar_mode = self.run_command("lshwres -r proc -m %s --level lpar --filter lpar_names=%s -F curr_proc_mode" %
(self.mg_system, lpar))
if "shared" in lpar_mode:
proc = self.run_command("lshwres -r proc -m %s --level lpar --filter lpar_names=%s -F curr_proc_units" %
(self.mg_system, lpar))
else:
proc = self.run_command("lshwres -r proc -m %s --level lpar --filter lpar_names=%s -F curr_procs" %
(self.mg_system, lpar))
if proc:
for proc_value in proc:
stealable_procs.append(int(float(proc_value)))
total_stealable_proc = sum(stealable_procs)
print("total stealable proc:", total_stealable_proc)
return total_stealable_proc

def get_stealable_mem_resources_lpar(self):
'''
we are getting the memory assigned to
not activated lpars
'''
stealable_mem = []
lpars = self.get_stealable_resources()
for lpar in lpars:
mem = self.run_command("lshwres -r mem -m %s --level lpar --filter lpar_names=%s -F curr_mem" %
(self.mg_system, lpar))
if mem:
for mem_value in mem:
stealable_mem.append(int(mem_value))
total_stealable_memory = sum(stealable_mem)
print("total stealable memory:", total_stealable_memory)
return total_stealable_memory

def get_lpar_state(self, vios=False, remote_hmc=None):
'''
Get current state of LPAR
Expand Down
11 changes: 5 additions & 6 deletions testcases/MachineConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def LparSetup(self, lpar_config=""):
except AttributeError:
self.desired_proc_units = 2.0
try:
self.max_proc_units = float(
self.cv_HMC.get_available_proc_resources()[0])
self.max_proc_units = int(float(
self.cv_HMC.get_available_proc_resources()[0])) + self.cv_HMC.get_stealable_proc_resources_lpar()
except AttributeError:
self.max_proc_units = 2.0
try:
Expand All @@ -269,8 +269,7 @@ def LparSetup(self, lpar_config=""):
try:
self.max_memory = conf.args.max_memory
except AttributeError:
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[0]) + \
int(self.desired_memory)
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[0]) + self.cv_HMC.get_stealable_mem_resources_lpar()
proc_mode = 'shared'
curr_proc_mode = self.cv_HMC.get_proc_mode()
if proc_mode in curr_proc_mode and not lpar_config:
Expand Down Expand Up @@ -312,7 +311,7 @@ def LparSetup(self, lpar_config=""):
self.max_proc_units = conf.args.max_proc_units
except AttributeError:
self.max_proc_units = int(
float(self.cv_HMC.get_available_proc_resources()[0]))
float(self.cv_HMC.get_available_proc_resources()[0])) + self.cv_HMC.get_stealable_proc_resources_lpar()
try:
self.min_memory = conf.args.min_memory
except AttributeError:
Expand All @@ -325,7 +324,7 @@ def LparSetup(self, lpar_config=""):
self.max_memory = conf.args.max_memory
except AttributeError:
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[
0]) + int(self.desired_memory)
0]) + self.cv_HMC.get_stealable_mem_resources_lpar()
proc_mode = 'ded'
self.cv_HMC.profile_bckup()
self.cv_HMC.change_proc_mode(proc_mode, self.sharing_mode,
Expand Down

0 comments on commit 39793c2

Please sign in to comment.