diff --git a/charms/slurmctld/requirements.txt b/charms/slurmctld/requirements.txt index 71fdf6b..d70c278 100644 --- a/charms/slurmctld/requirements.txt +++ b/charms/slurmctld/requirements.txt @@ -1,2 +1,2 @@ ops==2.17.1 -slurmutils~=0.11.0 +slurmutils<1.0.0,>=0.11.0 diff --git a/charms/slurmdbd/requirements.txt b/charms/slurmdbd/requirements.txt index 71fdf6b..d70c278 100644 --- a/charms/slurmdbd/requirements.txt +++ b/charms/slurmdbd/requirements.txt @@ -1,2 +1,2 @@ ops==2.17.1 -slurmutils~=0.11.0 +slurmutils<1.0.0,>=0.11.0 diff --git a/charms/slurmrestd/requirements.txt b/charms/slurmrestd/requirements.txt index 71fdf6b..d70c278 100644 --- a/charms/slurmrestd/requirements.txt +++ b/charms/slurmrestd/requirements.txt @@ -1,2 +1,2 @@ ops==2.17.1 -slurmutils~=0.11.0 +slurmutils<1.0.0,>=0.11.0 diff --git a/external/lib/charms/hpc_libs/v0/slurm_ops.py b/external/lib/charms/hpc_libs/v0/slurm_ops.py index 5652db6..1bc8729 100644 --- a/external/lib/charms/hpc_libs/v0/slurm_ops.py +++ b/external/lib/charms/hpc_libs/v0/slurm_ops.py @@ -77,8 +77,20 @@ def _on_install(self, _) -> None: import yaml from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import rsa -from slurmutils.editors import acctgatherconfig, cgroupconfig, slurmconfig, slurmdbdconfig -from slurmutils.models import AcctGatherConfig, CgroupConfig, SlurmConfig, SlurmdbdConfig +from slurmutils.editors import ( + acctgatherconfig, + cgroupconfig, + gresconfig, + slurmconfig, + slurmdbdconfig, +) +from slurmutils.models import ( + AcctGatherConfig, + CgroupConfig, + GRESConfig, + SlurmConfig, + SlurmdbdConfig, +) try: import charms.operator_libs_linux.v0.apt as apt @@ -97,14 +109,14 @@ def _on_install(self, _) -> None: # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 10 +LIBPATCH = 12 # Charm library dependencies to fetch during `charmcraft pack`. PYDEPS = [ "cryptography~=44.0.0", "pyyaml>=6.0.2", "python-dotenv~=1.0.1", - "slurmutils~=0.9.0", + "slurmutils<1.0.0,>=0.11.0", "distro~=1.9.0", ] @@ -245,26 +257,6 @@ def edit(self): """Edit the current configuration file.""" -class _SlurmConfigManager(_ConfigManager): - """Control the `slurm.conf` configuration file.""" - - def load(self) -> SlurmConfig: - """Load the current `slurm.conf` configuration file.""" - return slurmconfig.load(self._config_path) - - def dump(self, config: SlurmConfig) -> None: - """Dump new configuration into `slurm.conf` configuration file.""" - slurmconfig.dump(config, self._config_path, mode=0o644, user=self._user, group=self._group) - - @contextmanager - def edit(self) -> SlurmConfig: - """Edit the current `slurm.conf` configuration file.""" - with slurmconfig.edit( - self._config_path, mode=0o644, user=self._user, group=self._group - ) as config: - yield config - - class _AcctGatherConfigManager(_ConfigManager): """Manage the `acct_gather.conf` configuration file.""" @@ -309,6 +301,46 @@ def edit(self) -> CgroupConfig: yield config +class _GRESConfigManager(_ConfigManager): + """Manage the `gres.conf` configuration file.""" + + def load(self) -> GRESConfig: + """Load the current `gres.conf` configuration files.""" + return gresconfig.load(self._config_path) + + def dump(self, config: GRESConfig) -> None: + """Dump new configuration into `gres.conf` configuration file.""" + gresconfig.dump(config, self._config_path, mode=0o644, user=self._user, group=self._group) + + @contextmanager + def edit(self) -> GRESConfig: + """Edit the current `gres.conf` configuration file.""" + with gresconfig.edit( + self._config_path, mode=0o644, user=self._user, group=self._group + ) as config: + yield config + + +class _SlurmConfigManager(_ConfigManager): + """Control the `slurm.conf` configuration file.""" + + def load(self) -> SlurmConfig: + """Load the current `slurm.conf` configuration file.""" + return slurmconfig.load(self._config_path) + + def dump(self, config: SlurmConfig) -> None: + """Dump new configuration into `slurm.conf` configuration file.""" + slurmconfig.dump(config, self._config_path, mode=0o644, user=self._user, group=self._group) + + @contextmanager + def edit(self) -> SlurmConfig: + """Edit the current `slurm.conf` configuration file.""" + with slurmconfig.edit( + self._config_path, mode=0o644, user=self._user, group=self._group + ) as config: + yield config + + class _SlurmdbdConfigManager(_ConfigManager): """Control the `slurmdbd.conf` configuration file.""" @@ -951,6 +983,9 @@ def __init__(self, *args, **kwargs) -> None: self.cgroup = _CgroupConfigManager( self._ops_manager.etc_path / "cgroup.conf", self.user, self.group ) + self.gres = _GRESConfigManager( + self._ops_manager.etc_path / "gres.conf", self.user, self.group + ) class SlurmdManager(_SlurmManagerBase): diff --git a/test-requirements.txt b/test-requirements.txt index 25a39a2..3d41039 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,7 @@ cryptography~=43.0.1 distro==1.9.0 python-dotenv~=1.0.1 pycryptodome==3.20.0 -slurmutils~=0.11.0 +slurmutils<1.0.0,>=0.11.0 dbus-fast>=1.90.2 pyfakefs==5.7.1