def _restart_dnsmasq(self, ns_name, conf_file_path): pid = linux.find_process_by_cmdline([conf_file_path]) if pid: linux.kill_process(pid) NS_NAME = ns_name CONF_FILE = conf_file_path DNSMASQ = bash_errorout('which dnsmasq').strip(' \t\r\n') bash_errorout('ip netns exec {{NS_NAME}} {{DNSMASQ}} --conf-file={{CONF_FILE}} ') def check(_): pid = linux.find_process_by_cmdline([conf_file_path]) return pid is not None if not linux.wait_callback_success(check, None, 5): raise Exception('dnsmasq[conf-file:%s] is not running after being started %s seconds' % (conf_file_path, 5))
def handle_lv(lockType, fpath): if lockType > lvm.LvmlockdLockType.NULL: lvm.active_lv(fpath, lockType == lvm.LvmlockdLockType.SHARE) else: try: lvm.deactive_lv(fpath) except Exception as e: if not killProcess: return qemus = lvm.find_qemu_for_lv_in_use(fpath) if len(qemus) == 0: return for qemu in qemus: if qemu.state != "running": linux.kill_process(qemu.pid) lvm.deactive_lv(fpath)
def _restart_dnsmasq(self, ns_name, conf_file_path): pid = linux.find_process_by_cmdline([conf_file_path]) if pid: linux.kill_process(pid) cmd = '''\ ip netns exec {{ns_name}} /sbin/dnsmasq --conf-file={{conf_file}} || ip netns exec {{ns_name}} /usr/sbin/dnsmasq --conf-file={{conf_file}} ''' tmpt = Template(cmd) cmd = tmpt.render({'ns_name': ns_name, 'conf_file': conf_file_path}) shell.call(cmd) def check(_): pid = linux.find_process_by_cmdline([conf_file_path]) return pid is not None if not linux.wait_callback_success(check, None, 5): raise Exception('dnsmasq[conf-file:%s] is not running after being started %s seconds' % (conf_file_path, 5))