Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filesystem abstraction #205

Closed
tcaiazzi opened this issue Jan 30, 2023 · 1 comment
Closed

Add filesystem abstraction #205

tcaiazzi opened this issue Jan 30, 2023 · 1 comment
Assignees
Labels
enhancement next release The feature will be added in the next release
Milestone

Comments

@tcaiazzi
Copy link
Member

tcaiazzi commented Jan 30, 2023

We need to add a filesystem abstraction to the Lab and Machine classes to decouple the execution of Kathará from having a path on the host filesystem.

This will enable users to use Kathará API to fully configure a network scenario.

We plan to use the PyFilesystem2 library to add a fs variable representing the filesystem abstraction to Lab and Machine classes.

Skazza94 added a commit that referenced this issue Jan 30, 2023
Co-authored-by: Tommaso Caiazzi <tommasocaiazzi@gmail.com>
@Skazza94
Copy link
Member

Skazza94 commented Jan 31, 2023

Temptative Roadmap:

  • Introduce pyfilesystem into Lab and Machine classes
  • Lab: if constructor is called with path parameter, it means that it has a host folder in the OS filesystem (use osfs://). Otherwise, create an in-memory folder using mem:// filesystem.
  • Change Lab class to support new pyfilesystem reference, stored in fs.
  • Change Machine to reference the device folder by using the Lab.fs attribute, stored in fs.
  • Change the Machine.pack_data in order to create the tar file from the Machine.fs attribute.
  • Add a mixin FilesystemMixin that is inherited by Lab and Machine.
  • Add utility methods to FilesystemMixin to add a file in the filesystem reference:
    • Create FilesystemMixin.create_from_string(value: str, dst_path: str) that creates a file in the specified full destination path, with the content of the value parameter.
    • Create FilesystemMixin.create_from_path(src_path: str, dst_path: str) that creates a file in the specified full destination path, copying the content of the file in src_path.
    • Create FilesystemMixin.create_from_stream(stream: IO, dst_path: str) that creates a file in the specified full destination path, writing the content of the stream parameter.
  • Remove shared_startup_filename and shared_shutdown_filename from Lab constructor and recompute them everytime, so that if the file is added later it will be correctly uploaded.
  • Remove startup_filename and shutdown_filename from Machine constructor and recompute them everytime, so that if the file is added later it will be correctly uploaded.
  • Add docs strings to FilesystemMixin class.
  • Add unit tests for FilesystemMixin class.

Skazza94 added a commit that referenced this issue Feb 1, 2023
tcaiazzi added a commit that referenced this issue Feb 3, 2023
tcaiazzi added a commit that referenced this issue Feb 3, 2023
tcaiazzi added a commit that referenced this issue Feb 3, 2023
Skazza94 added a commit that referenced this issue Mar 8, 2023
@Skazza94 Skazza94 added the next release The feature will be added in the next release label Mar 8, 2023
@tcaiazzi tcaiazzi added this to the Release 3.6.0 milestone May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement next release The feature will be added in the next release
Projects
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants