How to use service_cgconfig_control method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...608 finally:609 proc_file.close()610 mount_path = re.findall(r":\S*,*%s,*\S*:(\S*)\n" % controller, proc_cgroup_txt)611 return os.path.join(root_path, mount_path[0].strip("/"))612def service_cgconfig_control(action):613 """614 Cgconfig control by action.615 If cmd executes successfully, return True, otherwise return False.616 If the action is status, return True when it's running, otherwise return617 False. To check if the cgconfig stuff is available, use action "exists".618 @ param action: start|stop|status|restart|condrestart619 """620 actions = ['start', 'stop', 'restart', 'condrestart']621 if action in actions:622 try:623"service cgconfig %s" % action)624 logging.debug("%s cgconfig successfully", action)625 return True626 except error.CmdError, detail:627 logging.error("Failed to %s cgconfig:\n%s", action, detail)628 return False629 elif action == "status" or action == "exists":630 cmd_result ="service cgconfig status", ignore_status=True)631 if action == "exists":632 if cmd_result.exit_status:633 return False634 else:635 return True636 if (not cmd_result.exit_status and637 cmd_result.stdout.strip()) == "Running":638"Cgconfig service is running")639 return True640 else:641 return False642 else:643 raise error.TestError("Unknown action: %s" % action)644# Split cgconfig action function, it will be more clear.645def cgconfig_start():646 """647 Stop cgconfig service648 """649 return service_cgconfig_control("start")650def cgconfig_stop():651 """652 Start cgconfig service653 """654 return service_cgconfig_control("stop")655def cgconfig_restart():656 """657 Restart cgconfig service658 """659 return service_cgconfig_control("restart")660def cgconfig_condrestart():661 """662 Condrestart cgconfig service663 """664 return service_cgconfig_control("condrestart")665def cgconfig_is_running():666 """667 Check cgconfig service status668 """669 return service_cgconfig_control("status")670def cgconfig_exists():671 """672 Check if cgconfig is available on the host or perhaps systemd is used673 """674 return service_cgconfig_control("exists")675def all_cgroup_delete():676 """677 Clear all cgroups in system678 """679 try:680"cgclear", ignore_status=False)681 except error.CmdError, detail:682 logging.warn("cgclear: Fail to clear all cgroups, some specific system"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?