def kill(self): """kill job in progress The process pid is owned by root, so that is not killable. Need to kill all its children. """ # the kill must be run as the kolla user so the # kolla_actions program must be used. try: actions_path = get_kolla_actions_path() cmd_prefix = ('%s job -t -p ' % actions_path) # kill the children from largest to smallest pids. child_pids = PidManager.get_child_pids(self._process.pid) for child_pid in sorted(child_pids, reverse=True): cmd = ''.join([cmd_prefix, child_pid]) err_msg, output = run_cmd(cmd, print_output=False) if err_msg: LOG.debug('kill failed: %s %s' % (err_msg, output)) else: LOG.debug('kill succeeded: %s' % child_pid) # record the name of user who killed the job cur_uid = os.getuid() self._kill_uname = pwd.getpwuid(cur_uid)[0] finally: self._cleanup()
def config_reset(): """Config Reset. Resets the kolla-ansible configuration to its release defaults. """ actions_path = utils.get_kolla_actions_path() cmd = ('%s config_reset' % actions_path) err_msg, output = utils.run_cmd(cmd, print_output=False) if err_msg: raise FailedOperation( u._('Configuration reset failed. {error} {message}').format( error=err_msg, message=output))
def _get_cmd_prefix(): actions_path = utils.get_kolla_actions_path() pwd_file_path = os.path.join(utils.get_kolla_etc(), PWDS_FILENAME) prefix = ('%s password -p %s ' % (actions_path, pwd_file_path)) return prefix