fixes commit
78c6656c9aba1d57786f916717c2622a3059fb6 which dropped
writing out the netmask but missed to add compat code for the case
where the caller did not suplly a address in CIDR format already.
Check if an address ends with /\d+, if not see if a netmask is
available and add that similar how it gets handled on read.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
my $raw = '';
$raw .= "iface $iface $family " . $d->{"method$suffix"} . "\n";
my $raw = '';
$raw .= "iface $iface $family " . $d->{"method$suffix"} . "\n";
- $raw .= "\taddress " . $d->{"address$suffix"} . "\n" if $d->{"address$suffix"};
+
+ if (my $addr = $d->{"address$suffix"}) {
+
+ if ($addr !~ /\/\d+$/ && $d->{"netmask$suffix"}) {
+ if ($d->{"netmask$suffix"} =~ m/^\d+$/) {
+ $addr .= "/" . $d->{"netmask$suffix"};
+ } elsif (my $mask = PVE::JSONSchema::get_netmask_bits($d->{"netmask$suffix"})) {
+ $addr .= "/" . $mask;
+ }
+ }
+
+ $raw .= "\taddress " . $addr . "\n";
+ }
+
$raw .= "\tgateway " . $d->{"gateway$suffix"} . "\n" if $d->{"gateway$suffix"};
my $done = { type => 1, priority => 1, method => 1, active => 1, exists => 1,
$raw .= "\tgateway " . $d->{"gateway$suffix"} . "\n" if $d->{"gateway$suffix"};
my $done = { type => 1, priority => 1, method => 1, active => 1, exists => 1,
auto eth1
iface eth1 inet6 static
auto eth1
iface eth1 inet6 static
gateway $gw
iface eth2 inet manual
gateway $gw
iface eth2 inet manual