filesystem-client

Filesystem Client

  • José Julián Espina Del Ángel
Channel Revision Published Runs on
latest/edge 15 17 Feb 2025
Ubuntu 24.04
juju deploy filesystem-client --channel edge
Show information

Platform:

Ubuntu
24.04

charms.filesystem_client.v0.filesystem_info

Library to manage integrations between filesystem providers and consumers.

This library contains the FilesystemProvides and FilesystemRequires classes for managing an integration between a filesystem server operator and a filesystem client operator.

FilesystemInfo (filesystem mount information)

This abstract class defines the methods that a filesystem type must expose for providers and consumers. Any subclass of this class will be compatible with the other methods exposed by the interface library, but the server and the client are the ones responsible for deciding which filesystems to support.

FilesystemRequires (filesystem client)

This class provides a uniform interface for charms that need to mount or unmount filesystems, and convenience methods for consuming data sent by a filesystem server charm.

Defined events
  • mount_filesystem: Event emitted when the filesystem is ready to be mounted.
  • umount_filesystem: Event emitted when the filesystem needs to be unmounted.
Example

``python import ops from charms.filesystem_client.v0.filesystem_info import ( FilesystemRequires, MountFilesystemEvent, )

class StorageClientCharm(ops.CharmBase): # Application charm that needs to mount filesystems.

def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)

    # Charm events defined in the FilesystemRequires class.
    self._fs = FilesystemRequires(self, "filesystem")
    self.framework.observe(
        self._fs.on.mount_filesystem,
        self._on_mount_filesystem,
    )

def _on_mount_filesystem(self, event: MountFilesystemEvent) -> None:
    # Handle when new filesystem server is connected.

    endpoint = event.endpoint

    self.mount("/mnt", endpoint.info)

    self.unit.status = ops.ActiveStatus("Mounted filesystem at `/mnt`.")

## FilesystemProvides (filesystem server)

This library provides a uniform interface for charms that expose filesystems.

> __Note:__ It is the responsibility of the provider charm to have
> the implementation for creating a new filesystem share. FilesystemProvides just exposes
> the interface for the integration.

### Example

```python
import ops
from charms.filesystem_client.v0.filesystem_info import (
    FilesystemProvides,
    NfsInfo,
)

class StorageServerCharm(ops.CharmBase):
    def __init__(self, framework: ops.Framework) -> None:
        super().__init__(framework)
        self._filesystem = FilesystemProvides(self, "filesystem", "server-peers")
        framework.observe(self.on.start, self._on_start)

    def _on_start(self, event: ops.StartEvent) -> None:
        # Handle start event.
        self._filesystem.set_info(NfsInfo("192.168.1.254", 65535, "/srv"))
        self.unit.status = ops.ActiveStatus()

class FilesystemInfoError

Description

Exception raised when an operation failed. None

class ParseUriError

Description

Exception raised when a parse operation from an URI failed. None

class FilesystemInfo

Information to mount a filesystem.

Description

This is an abstract class that exposes a set of required methods. All filesystems that can be handled by this library must derive this abstract class.

Methods

FilesystemInfo. from_uri( cls , uri: str , model: Model )

Description

Convert an URI string into a FilesystemInfo object. None

FilesystemInfo. to_uri( self , model: Model )

Description

Convert this FilesystemInfo object into an URI string. None

FilesystemInfo. grant( self , model: Model , relation )

Grant permissions for a certain relation to any secrets that this FilesystemInfo has.

Description

This is an optional method because not all filesystems will require secrets to be mounted on the client.

FilesystemInfo. filesystem_type( cls )

Description

Get the string identifier of this filesystem type. None

class NfsInfo

Description

Information required to mount an NFS share. None

Methods

NfsInfo. from_uri( cls , uri: str , _model: Model )

Description

See :py:meth:FilesystemInfo.from_uri for documentation on this method. None

NfsInfo. to_uri( self , _model: Model )

Description

See :py:meth:FilesystemInfo.to_uri for documentation on this method. None

NfsInfo. filesystem_type( cls )

Description

See :py:meth:FilesystemInfo.fs_type for documentation on this method. None

class CephfsInfo

Description

Information required to mount a CephFS share. None

Methods

CephfsInfo. from_uri( cls , uri: str , model: Model )

Description

See :py:meth:FilesystemInfo.from_uri for documentation on this method. None

CephfsInfo. to_uri( self , model: Model )

Description

See :py:meth:FilesystemInfo.to_uri for documentation on this method. None

CephfsInfo. grant( self , model: Model , relation: Relation )

Description

See :py:meth:FilesystemInfo.grant for documentation on this method. None

CephfsInfo. filesystem_type( cls )

Description

See :py:meth:FilesystemInfo.fs_type for documentation on this method. None

class LustreInfo

Description

Information required to mount a Luste share. None

Methods

LustreInfo. from_uri( cls , uri: str , _model: Model )

Description

See :py:meth:FilesystemInfo.from_uri for documentation on this method. None

LustreInfo. to_uri( self , _model: Model )

Description

See :py:meth:FilesystemInfo.to_uri for documentation on this method. None

LustreInfo. filesystem_type( cls )

Description

See :py:meth:FilesystemInfo.fs_type for documentation on this method. None

class Endpoint

Description

Endpoint data exposed by a filesystem server. None

class FilesystemEvent

Description

Base event for filesystem-related events. None

Methods

FilesystemEvent. endpoint( self )

Description

Get endpoint info. None

class MountFilesystemEvent

Description

Emit when a filesystem is ready to be mounted. None

class UmountFilesystemEvent

Description

Emit when a filesystem needs to be unmounted. None

class FilesystemRequiresEvents

Description

Events that FS servers can emit. None

class FilesystemRequires

Description

Consumer-side interface of filesystem integrations. None

Methods

FilesystemRequires. __init__( self , charm: CharmBase , relation_name: str )

FilesystemRequires. endpoints( self )

Description

List of endpoints exposed by all the relations of this charm. None

class FilesystemProvides

Description

Provider-side interface of filesystem integrations. None

Methods

FilesystemProvides. __init__( self , charm: CharmBase , relation_name: str , peer_relation_name: str )

FilesystemProvides. set_info( self , info: FilesystemInfo )

Set information to mount a filesystem.

Arguments

info

Information required to mount the filesystem.