Skip to content

Commit bc765b3

Browse files
Added support to get stealable resources from Not Activated lpars
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]>
1 parent 76e0d7e commit bc765b3

File tree

2 files changed

+70
-9
lines changed

2 files changed

+70
-9
lines changed

common/OpTestHMC.py

+65-3
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ def change_proc_mode(self, proc_mode, sharing_mode, min_proc_units, desired_proc
412412
self.set_lpar_cfg("proc_mode=shared,sharing_mode=%s,min_proc_units=%s,max_proc_units=%s,"
413413
"desired_proc_units=%s,min_procs=%s,desired_procs=%s,max_procs=%s,"
414414
"min_mem=%s,desired_mem=%s,max_mem=%s" %
415-
(sharing_mode, min_proc_units, max_proc_units, desired_proc_units,
416-
overcommit_ratio*int(min_proc_units), overcommit_ratio*int(desired_proc_units),
417-
3*int(max_proc_units),min_memory, desired_memory, max_memory))
415+
(sharing_mode, overcommit_ratio*int(min_proc_units), max_proc_units, overcommit_ratio*int(desired_proc_units),
416+
int(min_proc_units), overcommit_2*int(desired_proc_units),
417+
2*int(max_proc_units),min_memory, desired_memory, max_memory))
418418
elif proc_mode == 'ded':
419419
self.set_lpar_cfg("proc_mode=ded,sharing_mode=%s,min_procs=%s,max_procs=%s,desired_procs=%s,"
420420
"min_mem=%s,desired_mem=%s,max_mem=%s" %
@@ -599,6 +599,68 @@ def get_available_proc_resources(self):
599599
return self.run_command("lshwres -m %s -r proc --level sys -F curr_avail_sys_proc_units" %
600600
self.mg_system)
601601

602+
def get_stealable_resources(self):
603+
'''
604+
we are getting the not activated lpars
605+
list in order to steal the procs and mem resources
606+
'''
607+
output = self.run_command(
608+
"lssyscfg -r lpar -m %s -F name state" % self.mg_system)
609+
# Split the output into lines
610+
# lines = output.splitlines()
611+
# Initialize an empty list to store the first column values
612+
not_activated_lpars = []
613+
# Iterate over each line to extract the first column value if the state is "Not Activated"
614+
for line in output:
615+
# Split the line using space as the delimiter
616+
parts = line.split()
617+
# Check if the state is "Not Activated" and extract the first column value
618+
if len(parts) >= 2 and parts[1] == '"Not':
619+
lpar_name = parts[0]
620+
# Append the LPAR name to the list
621+
not_activated_lpars.append(lpar_name)
622+
return not_activated_lpars
623+
624+
def get_stealable_proc_resources_lpar(self):
625+
'''
626+
we are getting the procs assigned to not activated lpars
627+
'''
628+
stealable_procs = []
629+
lpars = self.get_stealable_resources()
630+
for lpar in lpars:
631+
632+
lpar_mode = self.run_command("lshwres -r proc -m %s --level lpar --filter lpar_names=%s -F curr_proc_mode" %
633+
(self.mg_system, lpar))
634+
if "shared" in lpar_mode:
635+
proc = self.run_command("lshwres -r proc -m %s --level lpar --filter lpar_names=%s -F curr_proc_units" %
636+
(self.mg_system, lpar))
637+
else:
638+
proc = self.run_command("lshwres -r proc -m %s --level lpar --filter lpar_names=%s -F curr_procs" %
639+
(self.mg_system, lpar))
640+
if proc:
641+
for proc_value in proc:
642+
stealable_procs.append(int(float(proc_value)))
643+
total_stealable_proc = sum(stealable_procs)
644+
print("total stealable proc:", total_stealable_proc)
645+
return total_stealable_proc
646+
647+
def get_stealable_mem_resources_lpar(self):
648+
'''
649+
we are getting the memory assigned to
650+
not activated lpars
651+
'''
652+
stealable_mem = []
653+
lpars = self.get_stealable_resources()
654+
for lpar in lpars:
655+
mem = self.run_command("lshwres -r mem -m %s --level lpar --filter lpar_names=%s -F curr_mem" %
656+
(self.mg_system, lpar))
657+
if mem:
658+
for mem_value in mem:
659+
stealable_mem.append(int(mem_value))
660+
total_stealable_memory = sum(stealable_mem)
661+
print("total stealable memory:", total_stealable_memory)
662+
return total_stealable_memory
663+
602664
def get_lpar_state(self, vios=False, remote_hmc=None):
603665
'''
604666
Get current state of LPAR

testcases/MachineConfig.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ def LparSetup(self, lpar_config=""):
250250
except AttributeError:
251251
self.desired_proc_units = 2.0
252252
try:
253-
self.max_proc_units = float(
254-
self.cv_HMC.get_available_proc_resources()[0])
253+
self.max_proc_units = int(float(
254+
self.cv_HMC.get_available_proc_resources()[0])) + self.cv_HMC.get_stealable_proc_resources_lpar()
255255
except AttributeError:
256256
self.max_proc_units = 2.0
257257
try:
@@ -269,8 +269,7 @@ def LparSetup(self, lpar_config=""):
269269
try:
270270
self.max_memory = conf.args.max_memory
271271
except AttributeError:
272-
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[0]) + \
273-
int(self.desired_memory)
272+
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[0]) + self.cv_HMC.get_stealable_mem_resources_lpar()
274273
proc_mode = 'shared'
275274
curr_proc_mode = self.cv_HMC.get_proc_mode()
276275
if proc_mode in curr_proc_mode and not lpar_config:
@@ -312,7 +311,7 @@ def LparSetup(self, lpar_config=""):
312311
self.max_proc_units = conf.args.max_proc_units
313312
except AttributeError:
314313
self.max_proc_units = int(
315-
float(self.cv_HMC.get_available_proc_resources()[0]))
314+
float(self.cv_HMC.get_available_proc_resources()[0])) + self.cv_HMC.get_stealable_proc_resources_lpar()
316315
try:
317316
self.min_memory = conf.args.min_memory
318317
except AttributeError:
@@ -325,7 +324,7 @@ def LparSetup(self, lpar_config=""):
325324
self.max_memory = conf.args.max_memory
326325
except AttributeError:
327326
self.max_memory = int(self.cv_HMC.get_available_mem_resources()[
328-
0]) + int(self.desired_memory)
327+
0]) + self.cv_HMC.get_stealable_mem_resources_lpar()
329328
proc_mode = 'ded'
330329
self.cv_HMC.profile_bckup()
331330
self.cv_HMC.change_proc_mode(proc_mode, self.sharing_mode,

0 commit comments

Comments
 (0)