From 39793c2440fcb72ecf7aa7d6837caf0a7b008dc0 Mon Sep 17 00:00:00 2001 From: Shirisha G Date: Mon, 3 Jun 2024 11:15:47 +0530 Subject: [PATCH] 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 --- common/OpTestHMC.py | 68 ++++++++++++++++++++++++++++++++++++-- testcases/MachineConfig.py | 11 +++--- 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/common/OpTestHMC.py b/common/OpTestHMC.py index 292647f7..084d6e9d 100644 --- a/common/OpTestHMC.py +++ b/common/OpTestHMC.py @@ -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" % @@ -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 diff --git a/testcases/MachineConfig.py b/testcases/MachineConfig.py index 10bf00b6..810bd07b 100755 --- a/testcases/MachineConfig.py +++ b/testcases/MachineConfig.py @@ -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: @@ -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: @@ -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: @@ -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,