From 8be43ac8ae941ea822fc0bf35449d3b84b6103e9 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Thu, 23 Jan 2025 13:57:30 +0000 Subject: [PATCH] stem: use Cylc host selection interface * The `ROSE_ORIG_HOST` variable is set using the Cylc interface. * The `HOST_SOURCE...` rose-stem variables are set using the Rose interface. * The two interfaces differ, Cylc picks long hostnames, Rose picks short ones. * The inconsistency may cause issues with simplistic "is this localhost" checks. * The shortnames are causing issues at one site. * Switch to using the Cylc interface for all scenarios. --- CHANGES.md | 6 ++++++ cylc/rose/stem.py | 8 ++++---- tests/functional/test_rose_stem.py | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a26e3ec1..326bd42e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,12 @@ creating a new release entry be sure to copy & paste the span tag with the updated. Only the first match gets replaced, so it's fine to leave the old ones in. --> +## __cylc-rose-1.5.0 (Awaiting release)__ + +[#361](https://github.com/cylc/cylc-rose/pull/361) - +Rose stem now uses long hostnames for the `HOST_SOURCE...` variables to match +`ROSE_ORIG_HOST`. + ## __cylc-rose-1.5.0 (Released 2025-01-09)__ [#353](https://github.com/cylc/cylc-rose/pull/353) - Remove Empy support. diff --git a/cylc/rose/stem.py b/cylc/rose/stem.py index 22fe7ee5..17a0787c 100644 --- a/cylc/rose/stem.py +++ b/cylc/rose/stem.py @@ -68,12 +68,14 @@ import sys from ansimarkup import parse as cparse + from cylc.flow.exceptions import CylcError +from cylc.flow.hostuserutil import get_host from cylc.flow.scripts.install import get_option_parser from cylc.flow.scripts.install import install as cylc_install + import metomi.rose.config from metomi.rose.fs_util import FileSystemUtil -from metomi.rose.host_select import HostSelector from metomi.rose.popen import RosePopener from metomi.rose.reporter import Event, Reporter from metomi.rose.resource import ResourceLocator @@ -239,8 +241,6 @@ def __init__(self, opts, reporter=None, popen=None, fs_util=None): else: self.fs_util = fs_util - self.host_selector = HostSelector(event_handler=self.reporter, - popen=self.popen) self.template_section = '[template variables]' def _add_define_option(self, var, val): @@ -429,7 +429,7 @@ def _prepend_localhost(self, url): locations.""" if ':' not in url or url.split(':', 1)[0] not in ['svn', 'fcm', 'http', 'https', 'svn+ssh']: - url = self.host_selector.get_local_host() + ':' + url + url = f'{get_host()}:{url}' return url def _parse_auto_opts(self): diff --git a/tests/functional/test_rose_stem.py b/tests/functional/test_rose_stem.py index d2b76063..d2ffa54d 100644 --- a/tests/functional/test_rose_stem.py +++ b/tests/functional/test_rose_stem.py @@ -28,17 +28,17 @@ from uuid import uuid4 from typing import Dict -from metomi.rose.host_select import HostSelector - import pytest +from cylc.flow.hostuserutil import get_host + from cylc.rose.stem import RoseStemVersionException # We want to test Rose-Stem's insertion of the hostname, # not Rose's method of getting the hostname, so it doesn't # Matter that we are using the same host selector here as # in the module under test: -HOST = HostSelector().get_local_host() +HOST = get_host() # Check that FCM is present on system, skipping checks elsewise: