Skip to content

Commit

Permalink
Merge pull request #1595 from jouvin/network_allow_short_hostname
Browse files Browse the repository at this point in the history
ncm-network core schema: allow realhostname to be a short hostname
  • Loading branch information
jrha committed Oct 2, 2023
2 parents f8dbf0f + 80fdbf9 commit 9cc4da5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Expand Up @@ -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.
Expand Down
15 changes: 14 additions & 1 deletion ncm-network/src/test/perl/simple.t
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
5 changes: 5 additions & 0 deletions ncm-network/src/test/resources/simple_shortrealhostname.pan
@@ -0,0 +1,5 @@
object template simple_shortrealhostname;

include 'simple_base_profile';

"/system/network/realhostname" = "shortrealhost";

0 comments on commit 9cc4da5

Please sign in to comment.