def ping(ip_address: str): if config.system == config.System.windows: packets_number_option = "-n" else: packets_number_option = "-c" cmd = ["ping", packets_number_option, "1", ip_address] try: util.run(cmd) return True except YurtException: return False
def run_vbox(args: List[str], **kwargs): """ See yurt.util.run for **kwargs documentation. """ executable = get_vboxmanage_executable() cmd = [executable, "-q"] + args try: return run(cmd, **kwargs) except CommandException as e: raise VBoxException(e.message)
def _ports_in_use(): ports = set() if config.system == config.System.windows: for line in util.run(["netstat", "-qnp", "TCP"]).split("\n"): cols = line.split() if len(cols) > 2 and cols[0] == "TCP": _, port = cols[1].split(":") ports.add(port) else: raise VMException(f"Unsupported platform: {config.system}") return ports
def run_lxc(args: List[str], **kwargs): """ See yurt.util.run for **kwargs documentation. """ lxc = get_lxc_executable() cmd = [lxc] + args lxc_env = { "HOME": config.config_dir } return run(cmd, env=lxc_env, **kwargs)