HPC Libs

  • José Julián Espina Del Ángel
Channel Revision Published Runs on
latest/stable 1 03 Jul 2024
Ubuntu 22.04
juju deploy hpc-libs
Show information

Platform:

Ubuntu
22.04

charms.hpc_libs.v0.is_container

Detect if machine is a container instance.

Even though Juju supports using LXD containers as the backing cloud for deploying charmed operators, not all HPC applications work within system containers, and some need additional configuration. This simple charm library provides utilities for identifying the virtualization runtime for a charmed operator.

Example Usage:
from charms.hpc_libs.v0.is_container import is_container

class ApplicationCharm(CharmBase):

    def __init__(self, *args):
        super().__init__(*args)

        self.framework.observe(self.on.install, self._on_install)

    def _on_install(self, _: InstallEvent) -> None:
        if is_container():
            self.unit.status = BlockedStatus("app does not support container runtime")

        # Proceed with installation.
        ...

class UnknownVirtStateError

Description

Raise error if unknown virtualization state is returned. None

Methods

UnknownVirtStateError. message( self )

Description

Return message passed as argument to exception. None

def is_container()

Detect if the machine is a container instance.