5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-08 21:18:03 +03:00

api2: create|restore|clone: add_free_ip

Co-Authored-by: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
Alexandre Derumier 2023-11-17 12:40:01 +01:00 committed by Wolfgang Bumiller
parent 6a6b668cf3
commit ee8d2dea5c
2 changed files with 21 additions and 0 deletions

View File

@ -991,6 +991,8 @@ __PACKAGE__->register_method({
eval { PVE::QemuServer::template_create($vmid, $restored_conf) };
warn $@ if $@;
}
PVE::QemuServer::create_ifaces_ipams_ips($restored_conf, $vmid) if $unique;
};
# ensure no old replication state are exists
@ -1069,6 +1071,8 @@ __PACKAGE__->register_method({
}
PVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool;
PVE::QemuServer::create_ifaces_ipams_ips($conf, $vmid);
};
PVE::QemuConfig->lock_config_full($vmid, 1, $realcmd);
@ -3778,6 +3782,8 @@ __PACKAGE__->register_method({
PVE::QemuConfig->write_config($newid, $newconf);
PVE::QemuServer::create_ifaces_ipams_ips($newconf, $newid);
if ($target) {
# always deactivate volumes - avoid lvm LVs to be active on several nodes
PVE::Storage::deactivate_volumes($storecfg, $vollist, $snapname) if !$running;

View File

@ -8658,4 +8658,19 @@ sub del_nets_bridge_fdb {
}
}
sub create_ifaces_ipams_ips {
my ($conf, $vmid) = @_;
return if !$have_sdn;
foreach my $opt (keys %$conf) {
if ($opt =~ m/^net(\d+)$/) {
my $value = $conf->{$opt};
my $net = PVE::QemuServer::parse_net($value);
eval { PVE::Network::SDN::Vnets::add_next_free_cidr($net->{bridge}, $conf->{name}, $net->{macaddr}, $vmid, undef, 1) };
warn $@ if $@;
}
}
}
1;