mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-01 08:05:24 +00:00
cloud-init: nocloud v1: set ip and netmask instead of cidr
because of centos7's broken cloud-init version Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
616aecc100
commit
862807898c
@ -137,6 +137,13 @@ sub cloudinit_userdata {
|
||||
return $content;
|
||||
}
|
||||
|
||||
sub split_ip4 {
|
||||
my ($ip) = @_;
|
||||
my ($addr, $mask) = split('/', $ip);
|
||||
die "not a CIDR: $ip\n" if !defined $mask;
|
||||
return ($addr, $PVE::Network::ipv4_reverse_mask->[$mask]);
|
||||
}
|
||||
|
||||
sub configdrive2_network {
|
||||
my ($conf) = @_;
|
||||
|
||||
@ -165,10 +172,10 @@ sub configdrive2_network {
|
||||
if ($net->{ip} eq 'dhcp') {
|
||||
$content .= "iface $id inet dhcp\n";
|
||||
} else {
|
||||
my ($addr, $mask) = split('/', $net->{ip});
|
||||
my ($addr, $mask) = split_ip4($net->{ip});
|
||||
$content .= "iface $id inet static\n";
|
||||
$content .= " address $addr\n";
|
||||
$content .= " netmask $PVE::Network::ipv4_reverse_mask->[$mask]\n";
|
||||
$content .= " netmask $mask\n";
|
||||
$content .= " gateway $net->{gw}\n" if $net->{gw};
|
||||
}
|
||||
}
|
||||
@ -321,8 +328,10 @@ sub nocloud_network {
|
||||
if ($ip eq 'dhcp') {
|
||||
$content .= "${i}- type: dhcp4\n";
|
||||
} else {
|
||||
my ($addr, $mask) = split_ip4($ip);
|
||||
$content .= "${i}- type: static\n"
|
||||
. "${i} address: $ip\n";
|
||||
. "${i} address: $addr\n"
|
||||
. "${i} netmask: $mask\n";
|
||||
if (defined(my $gw = $ipconfig->{gw})) {
|
||||
$content .= "${i} gateway: $gw\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user