Code for saving interfaces

This commit is contained in:
Jamie Cameron
2018-06-24 22:02:15 -07:00
parent 4ffda8b271
commit ed88a51ed1

View File

@@ -91,13 +91,22 @@ foreach my $f (glob("$netplan_dir/*.yaml")) {
return @rv;
}
# save_interface(&details)
# save_interface(&details, [&all-interfaces])
# Create or update a boot-time interface
sub save_interface
{
my ($iface) = @_;
if ($iface->{'alias'}) {
# XXX alias interface
my ($iface, $boot) = @_;
$boot ||= [ &boot_interfaces() ];
if ($iface->{'virtual'} ne '') {
# Find the parent config entry
my ($parent) = grep { $_->{'fullname'} eq $iface->{'name'} }
&boot_interfaces();
$parent || &error("No interface named $iface->{'name'} exists");
if (!$iface->{'file'}) {
# Add to complete interface list
push(@$boot, $iface);
}
&save_interface($parent, $boot);
}
else {
# Build interface config lines
@@ -116,6 +125,12 @@ else {
push(@addrs, $iface->{'address6'}->[$i]."/".
$iface->{'netmask6'}->[$i]);
}
foreach my $a (@$boot) {
if ($a->{'virtual'} ne '' && $a->{'name'} eq $iface->{'name'}) {
push(@addrs, $a->{'address'}."/".
&mask_to_prefix($a->{'netmask'}));
}
}
if (@addrs) {
push(@lines, $id." "."addresses: [".join(",", @addrs)."]");
}