Channel Revision Published Runs on
latest/edge 20 18 Jul 2025
Ubuntu 24.04
juju deploy filesystem-client --channel edge
Show information

Platform:

Ubuntu
24.04

charms.filesystem_client.v0.mount_info

Library to manage relations between a filesystem client and a mount requirer.

This library contains the MountProvides and MountRequires classes for managing a relation between a filesystem client operator and a mount requirer.

MountInfo (mount information)

This class defines information about the mount provided by the filesystem client.

MountRequires (filesystem client)

This class provides a uniform interface for charms that require a mounted shared filesystems, and convenience methods for consuming data sent by the filesystem client charm.

Defined events
  • connected: Event emitted when the filesystem client is ready to receive mount information.
  • mounted: Event emitted when the filesystem is mounted in the system.
  • unmounted: Event emitted when the filesystem is unmounted from the system.
  • disconnected: Event emitted when the filesystem client has disconnected from the mount requirer.
Example
import ops
from charms.filesystem_client.v0.mount_info import MountRequires, MountInfo

class MountClient(ops.CharmBase):

    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self._mount = MountRequires(self, "mount")
        self.framework.observe(self._mount.on.mount_provider_connected, self._on_mount_provider_connected)
        self.framework.observe(self._mount.on.mounted_filesystem, self._on_mounted_filesystem)
        self.framework.observe(self._mount.on.unmounted_filesystem, self._on_unmounted_filesystem)

    def _on_mount_provider_connected(self, event: EventBase) -> None:
        for relation in self._mount.relations:
            self._mount.set_mount_info(relation.id, MountInfo(mountpoint="/srv"))

        self.unit.status = ops.ActiveStatus()

    def _on_mounted_filesystem(self, _) -> None:
        self.write_files()

    def _on_unmounted_filesystem(self, _) -> None:
        self.recover_files()
MountProvides (filesystem client)

This library provides an interface for the filesystem client operator to receive mount share requests.

Defined events
  • requested: Event emitted when a mount requirer requests mounting a filesystem.
  • unrequested: Event emitted when the mount requirer withdraws its mount request.

class MountInfoError

Description

Exception raised when an operation failed. None

class MountInfo

Description

Information required to mount a filesystem. None

class MountProviderConnectedEvent

Description

Emit when a mount provider is waiting for the mount info. None

class MountedFilesystemEvent

Description

Emit when a mount provider has mounted the filesystem. None

class UnmountedFilesystemEvent

Description

Emit when a mount provider has unmounted the filesystem. None

class MountProviderDisconnectedEvent

Description

Emit when a mount provider has left the charm relation. None

class MountRequiresEvents

Description

Events that mount providers can emit. None

class MountRequires

Description

Consumer-side interface of mount integrations. None

Methods

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

MountRequires. set_mount_info( self , relation_id: int , info: MountInfo )

Set mount info for mounting the filesystem.

Arguments

relation_id

Identifier for the specific relation.

info

Information to mount the filesystem.

class MountRequestedEvent

Description

Emit when a mount requirer has provided the mount info. None

class MountUnrequestedEvent

Description

Emit when a mount requirer has removed its mount info. None

class MountProvidesEvents

Description

Events that mount requirers can emit. None

class MountProvides

Description

Provider-side interface of mount integrations. None

Methods

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

MountProvides. mount_info( self , relation_id: int )

Fetch the mount information of a relation.

Returns

MountInfo

information to mount a filesystem. None if the relation has not provided the required information.

Description

Notes: Method cannot be used in *-relation-broken events and will raise an exception.

MountProvides. set_mount_status( self , mounted: bool )

Set the current mount status of the filesystem.

Arguments

mounted

boolean representing the mount status of the filesystem.