From 80fdbf90f17cb6f3deeea482c6c39318bc0b91bd Mon Sep 17 00:00:00 2001 From: Michel Jouvin Date: Wed, 28 Jun 2023 15:47:04 +0200 Subject: [PATCH] ncm-network core schema: allow realhostname to be a short hostname - Allow better support of software like Ceph where it is the recommended setting --- .../main/pan/components/network/core-schema.pan | 2 +- ncm-network/src/test/perl/simple.t | 15 ++++++++++++++- .../test/resources/simple_shortrealhostname.pan | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 ncm-network/src/test/resources/simple_shortrealhostname.pan diff --git a/ncm-network/src/main/pan/components/network/core-schema.pan b/ncm-network/src/main/pan/components/network/core-schema.pan index 483c409cc5..47e4773f6e 100644 --- a/ncm-network/src/main/pan/components/network/core-schema.pan +++ b/ncm-network/src/main/pan/components/network/core-schema.pan @@ -421,7 +421,7 @@ type structure_ipv6 = { type structure_network = { "domainname" : type_fqdn "hostname" : type_shorthostname - "realhostname" ? type_fqdn + "realhostname" ? string with is_shorthostname(SELF) || is_fqdn(SELF) "default_gateway" ? type_ip @{When default_gateway is not set, the component will try to guess the default gateway using the first configured gateway set on an interface. diff --git a/ncm-network/src/test/perl/simple.t b/ncm-network/src/test/perl/simple.t index ebe6dcdeea..55bdf5df68 100644 --- a/ncm-network/src/test/perl/simple.t +++ b/ncm-network/src/test/perl/simple.t @@ -7,7 +7,7 @@ BEGIN { } use Test::More; -use Test::Quattor qw(simple simple_ethtool simple_noethtool simple_realhostname simple_nobroadcast simple_tun); +use Test::Quattor qw(simple simple_ethtool simple_noethtool simple_realhostname simple_shortrealhostname simple_nobroadcast simple_tun); use Test::MockModule; use NCM::Component::network; @@ -294,6 +294,19 @@ ok(command_history_ok([ ]), "hostnamectl called with realhostname"); +command_history_reset(); +$cfg = get_config_for_profile('simple_shortrealhostname'); +$executables{'/usr/bin/hostnamectl'} = 1; +is($cmp->Configure($cfg), 1, "Component runs correctly with shortrealhostname test profile w hostnamectl"); +unlike(get_file_contents("/etc/sysconfig/network"), + qr/HOSTNAME=/m, + "shortrealhostname not used as hostname w hostnamectl"); +ok(command_history_ok([ + '/usr/bin/hostnamectl set-hostname shortrealhost --static', +]), "hostnamectl called with shortrealhostname"); + + + # removing broadcast that was same as computed default is ok (triggers no network restart) set_desired_output('ipcalc --broadcast 4.3.2.1 255.255.255.0', "BROADCAST=4.3.2.255\n"); diff --git a/ncm-network/src/test/resources/simple_shortrealhostname.pan b/ncm-network/src/test/resources/simple_shortrealhostname.pan new file mode 100644 index 0000000000..3609f468ed --- /dev/null +++ b/ncm-network/src/test/resources/simple_shortrealhostname.pan @@ -0,0 +1,5 @@ +object template simple_shortrealhostname; + +include 'simple_base_profile'; + +"/system/network/realhostname" = "shortrealhost";