]>
git.proxmox.com Git - pve-network.git/blob - PVE/Network/SDN/Ipams.pm
1 package PVE
::Network
::SDN
::Ipams
;
9 use PVE
::Tools
qw(extract_param dir_glob_regex run_command);
10 use PVE
::Cluster
qw(cfs_read_file cfs_write_file cfs_lock_file);
13 use PVE
::Network
::SDN
::Ipams
::PVEPlugin
;
14 use PVE
::Network
::SDN
::Ipams
::NetboxPlugin
;
15 use PVE
::Network
::SDN
::Ipams
::PhpIpamPlugin
;
16 use PVE
::Network
::SDN
::Ipams
::Plugin
;
18 PVE
::Network
::SDN
::Ipams
::PVEPlugin-
>register();
19 PVE
::Network
::SDN
::Ipams
::NetboxPlugin-
>register();
20 PVE
::Network
::SDN
::Ipams
::PhpIpamPlugin-
>register();
21 PVE
::Network
::SDN
::Ipams
::Plugin-
>init();
24 sub sdn_ipams_config
{
25 my ($cfg, $id, $noerr) = @_;
27 die "no sdn ipam ID specified\n" if !$id;
29 my $scfg = $cfg->{ids
}->{$id};
30 die "sdn '$id' does not exist\n" if (!$noerr && !$scfg);
36 my $config = cfs_read_file
("sdn/ipams.cfg");
37 #add default internal pve
38 $config->{ids
}->{pve
}->{type
} = 'pve';
42 sub get_plugin_config
{
44 my $ipamid = $vnet->{ipam
};
45 my $ipam_cfg = PVE
::Network
::SDN
::Ipams
::config
();
46 return $ipam_cfg->{ids
}->{$ipamid};
52 cfs_write_file
("sdn/ipams.cfg", $cfg);
58 return keys %{$cfg->{ids
}};
61 sub complete_sdn_vnet
{
62 my ($cmdname, $pname, $cvalue) = @_;
64 my $cfg = PVE
::Network
::SDN
::Ipams
::config
();
66 return $cmdname eq 'add' ?
[] : [ PVE
::Network
::SDN
::Vnets
::sdn_ipams_ids
($cfg) ];