@@ -412,9 +412,9 @@ def change_proc_mode(self, proc_mode, sharing_mode, min_proc_units, desired_proc
412
412
self .set_lpar_cfg ("proc_mode=shared,sharing_mode=%s,min_proc_units=%s,max_proc_units=%s,"
413
413
"desired_proc_units=%s,min_procs=%s,desired_procs=%s,max_procs=%s,"
414
414
"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 ))
418
418
elif proc_mode == 'ded' :
419
419
self .set_lpar_cfg ("proc_mode=ded,sharing_mode=%s,min_procs=%s,max_procs=%s,desired_procs=%s,"
420
420
"min_mem=%s,desired_mem=%s,max_mem=%s" %
@@ -599,6 +599,68 @@ def get_available_proc_resources(self):
599
599
return self .run_command ("lshwres -m %s -r proc --level sys -F curr_avail_sys_proc_units" %
600
600
self .mg_system )
601
601
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
+
602
664
def get_lpar_state (self , vios = False , remote_hmc = None ):
603
665
'''
604
666
Get current state of LPAR
0 commit comments