示例#1
0
    def find_on_system(self):
        result = sh.run_command("pgrep -fl dnsmasq")
        processes = []
        for line in result:
            parts = line.split(" ")
            process_id = parts[0]
            process_args = dict()
            for arg in parts:
                # format: --arg_key=arg_val OR --arg_without_val
                if arg.startswith("--"):
                    arg_parts = arg.split("=")
                    # start from 3th char, # remove "--"
                    arg_name = arg_parts[0][2:]
                    arg_val = True
                    if len(arg_parts) > 1:
                        arg_val = arg_parts[1]
                    process_args[arg_name] = arg_val
            processes.append(DnsmasqProcess(process_id, process_args))

        return processes
示例#2
0
 def list_links(self):
     links = sh.run_command(["ip", "netns", "exec", self.ns, "ip", "link",
                             "list"])
     return links
示例#3
0
 def list_namespaces(cls):
     namespaces = sh.run_command(["ip", "netns", "list"])
     return namespaces