]>
git.proxmox.com Git - pve-network.git/blob - PVE/Network/SDN/Ipams.pm
1 package PVE
::Network
::SDN
::Ipams
;
8 use PVE
::Tools
qw(extract_param dir_glob_regex run_command);
9 use PVE
::Cluster
qw(cfs_read_file cfs_write_file cfs_lock_file);
12 use PVE
::Network
::SDN
::Ipams
::PVEPlugin
;
13 use PVE
::Network
::SDN
::Ipams
::NetboxPlugin
;
14 use PVE
::Network
::SDN
::Ipams
::PhpIpamPlugin
;
15 use PVE
::Network
::SDN
::Ipams
::Plugin
;
17 PVE
::Network
::SDN
::Ipams
::PVEPlugin-
>register();
18 PVE
::Network
::SDN
::Ipams
::NetboxPlugin-
>register();
19 PVE
::Network
::SDN
::Ipams
::PhpIpamPlugin-
>register();
20 PVE
::Network
::SDN
::Ipams
::Plugin-
>init();
23 sub sdn_ipams_config
{
24 my ($cfg, $id, $noerr) = @_;
26 die "no sdn ipam ID specified\n" if !$id;
28 my $scfg = $cfg->{ids
}->{$id};
29 die "sdn '$id' does not exist\n" if (!$noerr && !$scfg);
35 my $config = cfs_read_file
("sdn/ipams.cfg");
36 #add default internal pve
37 $config->{ids
}->{pve
}->{type
} = 'pve';
41 sub get_plugin_config
{
43 my $ipamid = $vnet->{ipam
};
44 my $ipam_cfg = PVE
::Network
::SDN
::Ipams
::config
();
45 return $ipam_cfg->{ids
}->{$ipamid};
51 cfs_write_file
("sdn/ipams.cfg", $cfg);
57 return keys %{$cfg->{ids
}};
60 sub complete_sdn_vnet
{
61 my ($cmdname, $pname, $cvalue) = @_;
63 my $cfg = PVE
::Network
::SDN
::Ipams
::config
();
65 return $cmdname eq 'add' ?
[] : [ PVE
::Network
::SDN
::Vnets
::sdn_ipams_ids
($cfg) ];