strip cidr from IP when dhcpd is in play

This commit is contained in:
mischa 2023-05-04 14:32:41 +02:00
parent ef79927dc2
commit f0de2c0e31
2 changed files with 9 additions and 3 deletions

View File

@ -157,7 +157,8 @@ sub render_dhcpd_conf {
my $_disk_format = $vms{$vm_name}{'format'} || $conf{'conf'}{'FORMAT'};
my $_disk = $conf{'conf'}{'IMAGES'} . "/" . $_instance . "." . $_disk_format;
my $_mac = $vms{$vm_name}{'mac'} || $conf{'conf'}{'MAC_PREFIX'} . ":" . $vms{$vm_name}{'vm_number'};
my $_ipv4 = $vms{$vm_name}{'ipv4'} || $conf{'conf'}{'IP_PREFIX'} . "." . ($conf{'conf'}{'IP_START'} + $vms{$vm_name}{'vm_number'});
my ($_ipv4_address, $_ipv4_subnet) = split(/\//, $vms{$vm_name}{'ipv4'}, 2) if $vms{$vm_name}{'ipv4'};
my $_ipv4 = $_ipv4_address || $conf{'conf'}{'IP_PREFIX'} . "." . ($conf{'conf'}{'IP_START'} + $vms{$vm_name}{'vm_number'});
my $_ipv6 = $vms{$vm_name}{'ipv6'} || $conf{'conf'}{'IPV6_PREFIX'} . ":" . ($conf{'conf'}{'IPV6_START'} + $vms{$vm_name}{'vm_number'}) . "::" . ($conf{'conf'}{'IP_START'} + $vms{$vm_name}{'vm_number'});
my $_hostname = $vms{$vm_name}{'hostname'};
@ -197,7 +198,7 @@ sub render_install_conf {
my $jot_pass = qx(jot -rcs '' 20 46 125);
chomp($jot_pass);
my $_ipv4 = $vms{$vm_name}{'ipv4'} || "autoconf";
my $_ipv4_gateway = $vms{$vm_name}{'ipv4_gw'} || "";
my $_ipv4_gateway = $vms{$vm_name}{'ipv4_gw'} || $conf{'conf'}{'ROUTER'};
my $_ipv6 = $vms{$vm_name}{'ipv6'} || $conf{'conf'}{'IPV6_PREFIX'} . ":" . ($conf{'conf'}{'IPV6_START'} + $vms{$vm_name}{'vm_number'}) . "::" . ($conf{'conf'}{'IP_START'} + $vms{$vm_name}{'vm_number'});
my $_ipv6_gateway = $vms{$vm_name}{'ipv6_gw'} || $conf{'conf'}{'IPV6_PREFIX'} . ":" . ($conf{'conf'}{'IPV6_START'} + $vms{$vm_name}{'vm_number'}) . "::1";
my $_username = $vms{$vm_name}{'username'};
@ -211,8 +212,12 @@ sub render_install_conf {
printf $fh_install "Network interfaces = vio0\n";
printf $fh_install "IPv4 address for vio0 = %s\n", $_ipv4;
printf $fh_install "IPv6 address for vio0 = %s\n", $_ipv6;
printf $fh_install "Default IPv4 route = %s\n", $_ipv4_gateway if $_ipv4_gateway;
printf $fh_install "Default IPv4 route = %s\n", $_ipv4_gateway if $_ipv4 ne "autoconf";
printf $fh_install "IPv6 default router = %s\n", $_ipv6_gateway;
printf $fh_install "DNS domain name = %s\n", "high5.nl" if $_ipv4 ne "autoconf";
printf $fh_install "DNS nameservers = %s\n", $conf{'conf'}{'DNS'} if $_ipv4 ne "autoconf";
printf $fh_install "Setup a user = %s\n", $_username;
printf $fh_install "Password for user = %s\n", $jot_pass;
printf $fh_install "Public ssh key for user = %s %s\n", $_sshkey, $jot_pass;

View File

@ -1,4 +1,5 @@
mac="fe:e1:ab:dd:73:a4"
ipv4="192.168.1.1/23"
owner="testuser1"
date="2018/04/02"
payment="74"