# not printing out options
} elsif ($d->{type} eq 'bridge') {
- $d->{bridge_ports} =~ s/[;,\s]+/ /g;
my $ports = $d->{bridge_ports} || 'none';
+ $ports =~ s/[;,\s]+/ /g;
$raw .= "\tbridge-ports $ports\n";
$done->{bridge_ports} = 1;
# check bond
foreach my $iface (keys %$ifaces) {
my $d = $ifaces->{$iface};
- if ($d->{type} eq 'bond' && $d->{slaves}) {
- my $bond_primary_is_slave = undef;
- foreach my $p (split (/\s+/, $d->{slaves})) {
- my $n = $ifaces->{$p};
- $n->{autostart} = 1;
+ next if !($d->{type} eq 'bond' && $d->{slaves});
- die "bond '$iface' - unable to find slave '$p'\n"
- if !$n;
- die "bond '$iface' - wrong interface type on slave '$p' " .
- "('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth';
- &$check_mtu($ifaces, $iface, $p);
- $bond_primary_is_slave = 1 if $d->{'bond-primary'} && $d->{'bond-primary'} eq $p;
- }
- die "bond '$iface' - bond-primary interface is not a slave" if $d->{'bond-primary'} && !$bond_primary_is_slave;
+ my $bond_primary_is_slave = undef;
+ foreach my $p (split (/\s+/, $d->{slaves})) {
+ my $n = $ifaces->{$p};
+ $n->{autostart} = 1;
+
+ die "bond '$iface' - unable to find slave '$p'\n" if !$n;
+ die "bond '$iface' - wrong interface type on slave '$p' ('$n->{type}' != 'eth or bond')\n"
+ if ($n->{type} ne 'eth' && $n->{type} ne 'bond');
+
+ $check_mtu->($ifaces, $iface, $p);
+ $bond_primary_is_slave = 1 if $d->{'bond-primary'} && $d->{'bond-primary'} eq $p;
}
+ die "bond '$iface' - bond-primary interface is not a slave" if $d->{'bond-primary'} && !$bond_primary_is_slave;
}
# check vxlan
$p = $1;
$vlanid = $2;
delete $d->{'vlan-raw-device'} if $d->{'vlan-raw-device'};
+ delete $d->{'vlan-id'} if $d->{'vlan-id'};
+
} else {
die "missing vlan-raw-device option" if !$d->{'vlan-raw-device'};
$p = $d->{'vlan-raw-device'};
foreach my $iface (keys %$ifaces_copy) {
my $d = $ifaces_copy->{$iface};
if ($d->{type} eq 'bridge') {
- foreach my $p (split (/\s+/, $d->{bridge_ports})) {
+ foreach my $p (split (/\s+/, $d->{bridge_ports} // '')) {
if($p =~ m/(\S+)\.(\d+)$/) {
my $vlanparent = $1;
if (!defined($ifaces_copy->{$p})) {
die "bridge '$iface' - unable to find bridge port '$p'\n" if !$n;
die "iface $p - ip address can't be set on interface if bridged in $iface\n"
if ($n->{method} && $n->{method} eq 'static' && $n->{address} ne '0.0.0.0') ||
- ($n->{method6} && $n->{method6} eq 'static' && $n->{address} ne '::');
+ ($n->{method6} && $n->{method6} eq 'static' && $n->{address6} ne '::');
&$check_mtu($ifaces_copy, $p, $iface);
$bridgeports->{$p} = $iface;
}
my ($rootiface, @rest) = split(/[.:]/, $iface);
my $childlevel = scalar(@rest);
- my $n = $ifaces->{$rootiface};
-
- my $pri = $if_type_hash->{$n->{type}} + $childlevel
- if $n->{type} && $n->{type} ne 'unknown';
+ my $type = $ifaces->{$rootiface}->{type};
+ return if !$type || $type eq 'unknown';
- return $pri;
+ return $if_type_hash->{$type} + $childlevel
};
foreach my $iface (sort {
my $raw = '';
- foreach my $machine (sort keys %$data) {
+ # sort longer entries first, so machine definitions with higher granularity are preferred
+ for my $machine (sort { length($b) <=> length($a) || $a cmp $b} keys %$data) {
my $d = $data->{$machine};
+ next if !defined($d); # allow "deleting" set entries
+
$raw .= "machine $machine\n";
$raw .= " login $d->{login}\n" if $d->{login};
$raw .= " password $d->{password}\n" if $d->{password};
sub write_apt_auth {
my ($filename, $fh, $data) = @_;
- my $raw = &$format_apt_auth_data($data);
+ my $raw = $format_apt_auth_data->($data);
die "write failed: $!" unless print $fh "$raw\n";
$orig->{$machine} = $data->{$machine};
}
- return &$format_apt_auth_data($orig);
+ return $format_apt_auth_data->($orig);
}
-register_file('apt-auth', "/etc/apt/auth.conf",
- \&read_apt_auth, \&write_apt_auth,
- \&update_apt_auth, perm => 0640);
+register_file(
+ 'apt-auth',
+ "/etc/apt/auth.conf",
+ \&read_apt_auth,
+ \&write_apt_auth,
+ \&update_apt_auth,
+ perm => 0640,
+);
1;