Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncm-network core schema: allow realhostname to be a short hostname #1595

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object template simple_shortrealhostname;

include 'simple_base_profile';

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