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: nmstate change the way dummy interfaces are created. #1683

Merged
merged 1 commit into from
May 15, 2024
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
8 changes: 3 additions & 5 deletions ncm-network/src/main/perl/nmstate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ sub is_valid_interface
# Filename is either right at the beginning or following a slash
(?: \A | / )
# $1 will capture for example:
# eth0 bond1 eth0.101 bond0.102
( \w+ \d+ (?: \. \d+ )? )
# eth0 bond1 eth0.101 bond0.102 or dummy_$key
( \w+ \d+ (?: \. \d+ )? | dummy_.* )
# Suffix (not captured)
\. yml \z
}x
Expand Down Expand Up @@ -717,13 +717,11 @@ sub Configure
if ($net->{manage_vips} && defined($net->{vips})) {
$self->verbose("Service address vips found, configuring dummy interfaces");
my $vips = $net->{vips};
my $idx = 0;
foreach my $name (sort keys %$vips) {
my $dummy_name = "dummy$idx";
my $dummy_name = "dummy_$name";
my $nmstate_dummy_cfg = $self->generate_vip_config($dummy_name, $vips->{$name});
my $dummy_filename = $self->iface_filename($dummy_name);
$exifiles->{$dummy_filename} = $self->nmstate_file_dump($dummy_filename, $nmstate_dummy_cfg);
$idx++;
}
};

Expand Down
16 changes: 16 additions & 0 deletions ncm-network/src/test/perl/nmstate_advance.t
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ routes:
next-hop-interface: bond0
EOF

Readonly my $DUMMY_YML => <<EOF;
# File generated by NCM::Component::nmstate. Do not edit
---
interfaces:
- ipv4:
address:
- ip: 4.3.2.10
prefix-length: 32
enabled: true
name: dummy_myvip
profile-name: dummy_myvip
state: up
type: dummy
EOF

Readonly my $IB_YML => <<EOF;
# File generated by NCM::Component::nmstate. Do not edit
Expand Down Expand Up @@ -272,5 +286,7 @@ is($ibyml, $IB_YML, "Exact ib0 yml config");
my $ibpkyml = get_file_contents("/etc/nmstate/ib1.12345.yml");
is($ibpkyml, $IBPKEY_YML, "Exact ib1 pkey yml config");

my $dummy_yml = get_file_contents("/etc/nmstate/dummy_myvip.yml");
is($dummy_yml, $DUMMY_YML, "Exact dummy interface yml config");

done_testing();
7 changes: 7 additions & 0 deletions ncm-network/src/test/resources/nmstate_advance.pan
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ prefix "/system/network/interfaces/ib1.12345";
"netmask" = "255.255.255.0";
"broadcast" = "10.11.15.255";
"type" = "Infiniband";

# Test creating dummy interface. aka loopback interface needed for vip, such as zebra.
"/system/network/manage_vips" = true;
prefix "/system/network/vips/myvip";
"fqdn" = "myvip.test.com";
"ip" = "4.3.2.10";
"interfaces/0" = "eth0";
Loading