@@ -40,34 +40,30 @@ class OpTestSysinfo():
4040 def __init__ (self ):
4141 with open (config_file , "r" ) as file :
4242 self .config_actions = yaml .safe_load (file )
43- list_of_commands = self .config_actions ["LINUX" ]["COMMANDS" ]
44- get_HMCconfig_cmds = self .config_actions ["HMC" ]["COMMANDS" ]
45-
46- def get_OSconfig (self , pty , prompt ):
47- # Collect config related data from the OS
48- try :
49- list_of_commands = self .config_actions ["LINUX" ]["COMMANDS" ]
50- print ("########### OS Sysinfo ########" )
51- for index , each_cmd in enumerate (list_of_commands , start = 0 ):
52- pty .sendline (each_cmd )
53- rc = pty .expect ([prompt , pexpect .TIMEOUT , pexpect .EOF ], timeout = 10 )
54- except CommandFailed as cf :
55- raise cf
56-
57- def get_HMCconfig (self , pty , prompt ,CEC_name ):
58- # Collect config data from HMC
59- ################ HMC INFO ####################
60- get_HMCconfig_cmds = self .config_actions ["HMC" ]["COMMANDS" ]
61- for index , each_cmd in enumerate (get_HMCconfig_cmds , start = 0 ):
62- if re .search ('SYS' , each_cmd ):
63- new_cmd = re .sub ('SYS' ,CEC_name ,each_cmd )
64- try :
65- output = pty .run_command (new_cmd )
66- except Exception as e :
43+
44+ def get_config (self , pty ,prompt ,CEC_name ,LPAR ,action_name ):
45+ # Collect config data based on action_name
46+ get_config_cmds = self .config_actions [action_name ]["COMMANDS" ]
47+ for index , each_cmd in enumerate (get_config_cmds , start = 0 ):
48+ if re .search (r'SYS|LPAR_NAME' , each_cmd ):
49+ new_cmd = each_cmd
50+ # Replace placeholders
51+ new_cmd = re .sub (r'SYS' , CEC_name , new_cmd )
52+ new_cmd = re .sub (r'LPAR_NAME' , LPAR , new_cmd )
53+ try :
54+ if action_name in ['HMC' , 'IO' ]:
55+ output = pty .run_command (new_cmd )
56+ else :
57+ pty .sendline (new_cmd )
58+ rc = pty .expect ([prompt , pexpect .TIMEOUT , pexpect .EOF ], timeout = 10 )
59+ except Exception as e :
6760 print ('command failed due to system error' )
6861 else :
6962 try :
70- output = pty .run_command (each_cmd )
63+ if action_name == 'HMC' :
64+ output = pty .run_command (each_cmd )
65+ else :
66+ pty .sendline (each_cmd )
67+ rc = pty .expect ([prompt , pexpect .TIMEOUT , pexpect .EOF ], timeout = 10 )
7168 except Exception as e :
72- print ('command failed due to system error' )
73-
69+ print ('command failed due to system error' )
0 commit comments