Skip to content

Commit

Permalink
host-select: expand paths in filesystem arguments
Browse files Browse the repository at this point in the history
* restores the default filesystem to ~
  • Loading branch information
oliver-sanders committed Mar 25, 2021
1 parent 241fb6c commit 3b834a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion metomi/rose/host_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ class FileSystemScorer(RandomScorer):

"""Score host by average file system percentage usage."""

ARG = "/" # TODO?
ARG = "~"
KEY = "fs"

def get_command(self, method_arg):
Expand Down
13 changes: 11 additions & 2 deletions metomi/rose/host_select_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
import json
from pathlib import Path
import sys

import psutil
Expand All @@ -40,8 +41,16 @@ def main():

# extract metrics using psutil
ret = [
getattr(psutil, key[0])(*key[1:])
for key in metrics
getattr(psutil, key)(
*args
if key != 'disk_usage'
else [
# expand ~ in paths for disk usage queries
Path(arg).expanduser()
for arg in args
]
)
for key, *args in metrics
]

# serialise results
Expand Down

0 comments on commit 3b834a8

Please sign in to comment.