Filesystem

Filesystem represents abstract API definition. It is now implemented by conu.DockerContainerViaExportFS

class conu.apidefs.filesystem.Filesystem(object_instance, mount_point=None)

Utility methods used to access filesystem of containers and images.

Implementations should probably be done using context managers.

__init__(object_instance, mount_point=None)
Parameters:
  • object_instance – instance of the container or image
  • mount_point – str, directory where the filesystem will be mounted
copy_from(src, dest)

copy a file or a directory from container or image to host system. If you are copying directories, the target directory must not exist (this function is using shutil.copytree to copy directories and that’s a requirement of the function). In case the directory exists, OSError on python 2 or FileExistsError on python 3 are raised.

Parameters:
  • src – str, path to a file or a directory within container or image
  • dest – str, path to a file or a directory on host system
Returns:

None

copy_to(src, dest)

copy a file or a directory from host system to a container – don’t implement for images, those are immutable

Parameters:
  • src – str, path to a file or a directory on host system
  • dest – str, path to a file or a directory within container
Returns:

None

directory_is_present(directory_path)

check if directory ‘directory_path’ is present, raise IOError if it’s not a directory

Parameters:directory_path – str, directory to check
Returns:True if directory exists, False if directory does not exist
file_is_present(file_path)

check if file ‘file_path’ is present, raises IOError if file_path is not a file

Parameters:file_path – str, path to the file
Returns:True if file exists, False if file does not exist
get_file(file_path, mode='r')

provide File object specified via ‘file_path’

Parameters:
  • file_path – str, path to the file
  • mode – str, mode used when opening the file
Returns:

File instance

get_selinux_context(file_path)

Get SELinux file context of the selected file.

Parameters:file_path – str, path to the file
Returns:str, name of the SELinux file context
p(path)

provide absolute path within the container

Parameters:path – path with container
Returns:str
read_file(file_path)

read file specified via ‘file_path’ and return its content - raises an ConuException if there is an issue accessing the file

Parameters:file_path – str, path to the file to read
Returns:str (not bytes), content of the file