mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-05 10:58:09 +00:00
API2: Network: allow cidr-list && use cidr for address
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
dcd887f4c0
commit
3b82e4cf43
@ -152,7 +152,7 @@ my $confdesc = {
|
|||||||
},
|
},
|
||||||
cidr => {
|
cidr => {
|
||||||
description => 'IPv4 CIDR.',
|
description => 'IPv4 CIDR.',
|
||||||
type => 'string', format => 'CIDRv4',
|
type => 'string', format => 'CIDRv4-list',
|
||||||
optional => 1,
|
optional => 1,
|
||||||
},
|
},
|
||||||
mtu => {
|
mtu => {
|
||||||
@ -181,7 +181,7 @@ my $confdesc = {
|
|||||||
},
|
},
|
||||||
cidr6 => {
|
cidr6 => {
|
||||||
description => 'IPv6 CIDR.',
|
description => 'IPv6 CIDR.',
|
||||||
type => 'string', format => 'CIDRv6',
|
type => 'string', format => 'CIDRv6-list',
|
||||||
optional => 1,
|
optional => 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -326,11 +326,14 @@ my $map_cidr_to_address_netmask = sub {
|
|||||||
if $param->{address};
|
if $param->{address};
|
||||||
raise_param_exc({ netmask => "netmask conflicts with cidr" })
|
raise_param_exc({ netmask => "netmask conflicts with cidr" })
|
||||||
if $param->{netmask};
|
if $param->{netmask};
|
||||||
|
my @cidrs = split /,/, $param->{cidr};
|
||||||
|
foreach my $cidr (@cidrs) {
|
||||||
|
push @{$param->{address}}, $cidr;
|
||||||
|
}
|
||||||
|
|
||||||
my ($address, $netmask) = $param->{cidr} =~ m!^(.*)/(\d+)$!;
|
|
||||||
$param->{address} = $address;
|
|
||||||
$param->{netmask} = $netmask;
|
|
||||||
delete $param->{cidr};
|
delete $param->{cidr};
|
||||||
|
} elsif ($param->{address} && $param->{netmask}) {
|
||||||
|
$param->{address} = ["$param->{address}/$param->{netmask}"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($param->{cidr6}) {
|
if ($param->{cidr6}) {
|
||||||
@ -339,10 +342,14 @@ my $map_cidr_to_address_netmask = sub {
|
|||||||
raise_param_exc({ netmask6 => "netmask6 conflicts with cidr6" })
|
raise_param_exc({ netmask6 => "netmask6 conflicts with cidr6" })
|
||||||
if $param->{netmask6};
|
if $param->{netmask6};
|
||||||
|
|
||||||
my ($address, $netmask) = $param->{cidr6} =~ m!^(.*)/(\d+)$!;
|
my @cidrs = split /,/, $param->{cidr6};
|
||||||
$param->{address6} = $address;
|
foreach my $cidr (@cidrs) {
|
||||||
$param->{netmask6} = $netmask;
|
push @{$param->{address6}}, $cidr;
|
||||||
|
}
|
||||||
delete $param->{cidr6};
|
delete $param->{cidr6};
|
||||||
|
|
||||||
|
} elsif ($param->{address6} && $param->{netmask6}) {
|
||||||
|
$param->{address} = ["$param->{address6}/$param->{netmask6}"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user