diff --git a/common/OpTestHMC.py b/common/OpTestHMC.py index de947375..292647f7 100644 --- a/common/OpTestHMC.py +++ b/common/OpTestHMC.py @@ -180,9 +180,7 @@ def check_lpar_secureboot_state(self, hmc_con): def hmc_secureboot_on_off(self, enable=True): ''' Enable/Disable Secure Boot from HMC - 1. PowerOFF/Shutdown LPAR from HMC - 2. Enable/Disable Secure boot using 'chsyscfg' command - 3. PowerON/Activate the LPAR and boot to Operating System + Enable/Disable Secure boot using 'chsyscfg' command ''' # Set Secure Boot value using HMC command cmd = ('chsyscfg -r lpar -m %s -i "name=%s, secure_boot=' % @@ -863,6 +861,34 @@ def is_msp_enabled(self, mg_system, vios_name, remote_hmc=None): if int(msp_output[0]) != 1: return False return True + + def is_perfcollection_enabled(self): + ''' + Get Performance Information collection allowed in hmc profile + + :returns: Ture if allow_perf_collection in hmc otherwise false + ''' + + rc = self.run_command("lssyscfg -m %s -r lpar --filter lpar_names=%s -F allow_perf_collection" + % (self.mg_system, self.lpar_name)) + if rc: + return True + return False + + def hmc_perfcollect_configure(self, enable=True): + ''' + Enable/Disable perfcollection from HMC + The value for enabling perfcollection is 1, and for disabling it is 0. + ''' + + cmd = ('chsyscfg -r lpar -m %s -i "name=%s, allow_perf_collection=' % + (self.mg_system, self.lpar_name)) + if enable: + cmd = '%s1"' % cmd + else: + cmd = '%s0"' % cmd + self.run_command(cmd, timeout=300) + def gather_logs(self, list_of_commands=[], remote_hmc=None, output_dir=None): ''' diff --git a/common/OpTestUtil.py b/common/OpTestUtil.py index 03e2d567..f386edd9 100644 --- a/common/OpTestUtil.py +++ b/common/OpTestUtil.py @@ -1484,9 +1484,9 @@ def get_login(self, host, term_obj, pty, prompt): if rc == 0: pty.sendline(my_pwd) time.sleep(0.5) - rc = pty.expect(['login: $', ".*#$", ".*# $", ".*\$", "~ #", + rc = pty.expect(['login: $', ".*#$", ".*# $", ".*\$", "~ #", ":~", 'Petitboot', pexpect.TIMEOUT, pexpect.EOF], timeout=60) - if rc not in [1, 2, 3, 4]: + if rc not in [1, 2, 3, 4, 5]: if term_obj.setup_term_quiet == 0: log.warning("OpTestSystem Problem with the login and/or password prompt," " raised Exception ConsoleSettings but continuing") @@ -1518,9 +1518,9 @@ def get_login(self, host, term_obj, pty, prompt): if rc == 0: pty.sendline(my_pwd) time.sleep(0.5) - rc = pty.expect(['login: $', ".*#$", ".*# $", ".*\$", "~ #", + rc = pty.expect(['login: $', ".*#$", ".*# $", ".*\$", "~ #", ":~", 'Petitboot', pexpect.TIMEOUT, pexpect.EOF], timeout=10) - if rc not in [1, 2, 3, 4]: + if rc not in [1, 2, 3, 4, 5]: if term_obj.setup_term_quiet == 0: log.warning("OpTestSystem Problem with the login and/or password prompt," " raised Exception ConsoleSettings but continuing") @@ -1688,14 +1688,14 @@ def setup_term(self, system, pty, ssh_obj=None, block=0): # Ctrl-L may cause a esc[J (erase) character to appear in the buffer. # Include this in the patterns that expect $ (end of line) rc = pty.expect(['login: (\x1b\[J)*$', ".*#(\x1b\[J)*$", ".*# (\x1b\[J)*$", ".*\$(\x1b\[J)*", - "~>(\x1b\[J)", "~ #(\x1b\[J)", 'Petitboot', pexpect.TIMEOUT, pexpect.EOF], timeout=10) + "~>(\x1b\[J)", "~ #(\x1b\[J)", ":~(\x1b\[J)", 'Petitboot', pexpect.TIMEOUT, pexpect.EOF], timeout=10) if rc == 0: track_obj.PS1_set, track_obj.LOGIN_set = self.get_login( system_obj.cv_HOST, term_obj, pty, self.build_prompt(system_obj.prompt)) track_obj.PS1_set, track_obj.SUDO_set = self.get_sudo( system_obj.cv_HOST, term_obj, pty, self.build_prompt(system_obj.prompt)) return - if rc in [1, 2, 3, 4, 5]: + if rc in [1, 2, 3, 4, 5, 6]: track_obj.LOGIN_set = track_obj.PS1_set = self.set_PS1( term_obj, pty, self.build_prompt(system_obj.prompt)) track_obj.PS1_set, track_obj.SUDO_set = self.get_sudo( diff --git a/testcases/MachineConfig.py b/testcases/MachineConfig.py index 61d4afaf..10bf00b6 100755 --- a/testcases/MachineConfig.py +++ b/testcases/MachineConfig.py @@ -203,7 +203,7 @@ class LparConfig(): valid values: cpu=shared or cpu=dedicated vtpm=1 or vtpm=0 vpmem=0 or vpmem=1 - Ex: machine_config="cpu=dedicated,vtpm=1,vpmem=1" + Ex: machine_config="cpu=dedicated,vtpm=1,vpmem=1,perf=1" ''' def __init__(self, cv_HMC=None, system_name=None, @@ -421,6 +421,17 @@ def LparSetup(self, lpar_config=""): if self.sb_enable is not None: self.cv_HMC.hmc_secureboot_on_off(self.sb_enable) + + if "perf=1" in self.machine_config: + conf = OpTestConfiguration.conf + if self.cv_HMC.is_perfcollection_enabled(): + log.info("System is already booted with perf collection profile enabled") + else: + self.cv_HMC.hmc_perfcollect_configure() + if self.cv_HMC.is_perfcollection_enabled: + log.info("System is already booted with perf collection profile enabled") + else: + return "Failed to enable Performance Information collection" self.cv_HMC.poweron_lpar() curr_proc_mode = self.cv_HMC.get_proc_mode()