def interface_list() -> List[str]: """ Discover available host interfaces """ cmd_ip = system_command('ip') command = f"{cmd_ip} -o addr show up primary scope global".split() result = SUDO.execute_unit(command) result.assert_return() line_list = result.stdout.splitlines() pattern = re.compile(r"^\d+[:]\s+(\S+)\s+(.+)$") select = lambda line: pattern.search(line).group(1) face_list = list(map(select, line_list)) return face_list
def nspawn_exec_stop(self) -> Command: """ Container stop command """ program = system_command('true') return Command([program])
def file_create(self, path) -> Command: touch = system_command('touch') return Command([touch, '-a', path])
def folder_delete(self, path) -> Command: rm = system_command('rm') return Command([rm, '-r', '-f', path])
def folder_create(self, path) -> Command: mkdir = system_command('mkdir') return Command([mkdir, '-p', path])
def mount_point_desure(self) -> Command: # TODO shell = system_command('sh') test = " ".join(self.mount_point_test()) delete = " ".join(self.mount_point_delete()) return Command([shell, '-c', f"while {test} ; do {delete} ; sleep {self.delay} ; done" ])
def mount_point_ensure(self) -> Command: # TODO shell = system_command('sh') test = " ".join(self.mount_point_test()) create = " ".join(self.mount_point_create()) return Command([shell, '-c', f"until {test} ; do {create} ; sleep {self.delay} ; done" ])
def mount_point_delete(self) -> Command: umount = system_command('umount') point = self.machine_store.mount_point() return Command([umount, point])
def mount_point_create(self) -> Command: mount = system_command('mount') point = self.machine_store.mount_point() options = self.mount_options() return Command([mount, '-t', 'overlay', '-o', options, 'overlay', point])
def mount_point_test(self) -> Command: test = system_command('mountpoint') point = self.machine_store.mount_point() return Command([test, point])