Пример #1
0
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
Пример #2
0
 def nspawn_exec_stop(self) -> Command:
     """
     Container stop command
     """
     program = system_command('true')
     return Command([program])
Пример #3
0
 def file_create(self, path) -> Command:
     touch = system_command('touch')
     return Command([touch, '-a', path])
Пример #4
0
 def folder_delete(self, path) -> Command:
     rm = system_command('rm')
     return Command([rm, '-r', '-f', path])
Пример #5
0
 def folder_create(self, path) -> Command:
     mkdir = system_command('mkdir')
     return Command([mkdir, '-p', path])
Пример #6
0
 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" ])
Пример #7
0
 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" ])
Пример #8
0
 def mount_point_delete(self) -> Command:
     umount = system_command('umount')
     point = self.machine_store.mount_point()
     return Command([umount, point])
Пример #9
0
 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])
Пример #10
0
 def mount_point_test(self) -> Command:
     test = system_command('mountpoint')
     point = self.machine_store.mount_point()
     return Command([test, point])