From d46aaa73fedd9eba75ee7a08dce07f9e256e1692 Mon Sep 17 00:00:00 2001 From: Andreas Naumann Date: Mon, 23 Oct 2023 16:41:38 +0200 Subject: [PATCH] remote/exporter: Add option to default to fqdn for hostname In distributed setups, the coordinator may point to exporters/places in different subnets. In order for clients to resolve resources behind the exporter, they need to know its FQDN instead of just the hostname. Using an option to change the default avoids conflicts for configs which rely on the hostname only. Signed-off-by: Andreas Naumann --- labgrid/remote/exporter.py | 9 ++++++++- man/labgrid-exporter.1 | 8 ++++++++ man/labgrid-exporter.rst | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/labgrid/remote/exporter.py b/labgrid/remote/exporter.py index a30b1afe1..eaff020a5 100755 --- a/labgrid/remote/exporter.py +++ b/labgrid/remote/exporter.py @@ -916,6 +916,13 @@ def main(): default=None, help='hostname (or IP) published for accessing resources (defaults to the system hostname)' ) + parser.add_argument( + '-f', + '--fqdn', + action='store_true', + default=False, + help='Use fully qualified domain name as default for hostname' + ) parser.add_argument( '-d', '--debug', @@ -943,7 +950,7 @@ def main(): extra = { 'name': args.name or gethostname(), - 'hostname': args.hostname or gethostname(), + 'hostname': args.hostname or getfqdn() if args.fqdn else gethostname(), 'resources': args.resources, 'isolated': args.isolated } diff --git a/man/labgrid-exporter.1 b/man/labgrid-exporter.1 index 20fe4b522..4cb93e6bf 100644 --- a/man/labgrid-exporter.1 +++ b/man/labgrid-exporter.1 @@ -59,6 +59,9 @@ the public name of the exporter .B \-\-hostname hostname (or IP) published for accessing resources .TP +.B \-f\fP,\fB \-\-fqdn +use fully qualified domain name as default for hostname +.TP .B \-d\fP,\fB \-\-debug enable debug mode .UNINDENT @@ -83,6 +86,11 @@ exporter needs to provide a host name to set the exported value of the \(dqhost\ key. If the system hostname is not resolvable via DNS, this option can be used to override this default with another name (or an IP address). +.SS \-f \-\-fqdn +.sp +In some networks the fully qualified domain name may be needed to reach resources +on an exporter. This option changes the default to fqdn when no \-\-hostname is +explicitly set. .SH CONFIGURATION .sp The exporter uses a YAML configuration file which defines groups of related diff --git a/man/labgrid-exporter.rst b/man/labgrid-exporter.rst index 8c9bda9dc..575a999f1 100644 --- a/man/labgrid-exporter.rst +++ b/man/labgrid-exporter.rst @@ -46,6 +46,8 @@ OPTIONS the public name of the exporter --hostname hostname (or IP) published for accessing resources +-f, --fqdn + use fully qualified domain name as default for hostname -d, --debug enable debug mode @@ -73,6 +75,12 @@ key. If the system hostname is not resolvable via DNS, this option can be used to override this default with another name (or an IP address). +-f --fqdn +~~~~~~~~~ +In some networks the fully qualified domain name may be needed to reach resources +on an exporter. This option changes the default to fqdn when no --hostname is +explicitly set. + CONFIGURATION ------------- The exporter uses a YAML configuration file which defines groups of related