]>
git.proxmox.com Git - pve-network.git/blob - src/PVE/Network/SDN/Ipams/Plugin.pm
1 package PVE
::Network
::SDN
::Ipams
::Plugin
;
6 use PVE
::Tools
qw(run_command);
14 use PVE
::JSONSchema
qw(get_standard_option);
15 use base
qw(PVE::SectionConfig);
17 PVE
::Cluster
::cfs_register_file
('sdn/ipams.cfg',
18 sub { __PACKAGE__-
>parse_config(@_); },
19 sub { __PACKAGE__-
>write_config(@_); });
21 PVE
::JSONSchema
::register_standard_option
('pve-sdn-ipam-id', {
22 description
=> "The SDN ipam object identifier.",
23 type
=> 'string', format
=> 'pve-sdn-ipam-id',
26 PVE
::JSONSchema
::register_format
('pve-sdn-ipam-id', \
&parse_sdn_ipam_id
);
27 sub parse_sdn_ipam_id
{
28 my ($id, $noerr) = @_;
30 if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
31 return undef if $noerr;
32 die "ipam ID '$id' contains illegal characters\n";
41 description
=> "Plugin type.",
42 type
=> 'string', format
=> 'pve-configid',
45 ipam
=> get_standard_option
('pve-sdn-ipam-id',
46 { completion
=> \
&PVE
::Network
::SDN
::Ipams
::complete_sdn_ipam
}),
54 sub parse_section_header
{
55 my ($class, $line) = @_;
57 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
58 my ($type, $id) = (lc($1), $2);
59 my $errmsg = undef; # set if you want to skip whole section
60 eval { PVE
::JSONSchema
::pve_verify_configid
($type); };
62 my $config = {}; # to return additional attributes
63 return ($type, $id, $errmsg, $config);
70 my ($class, $plugin_config, $subnetid, $subnet, $noerr) = @_;
72 die "please implement inside plugin";
76 my ($class, $plugin_config, $subnetid, $subnet, $noerr) = @_;
78 die "please implement inside plugin";
82 my ($class, $plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway, $noerr) = @_;
84 die "please implement inside plugin";
88 my ($class, $plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway, $noerr) = @_;
89 # only update ip attributes (mac,hostname,..). Don't change the ip addresses itself, as some ipam
90 # don't allow ip address change without del/add
92 die "please implement inside plugin";
96 my ($class, $plugin_config, $subnetid, $subnet, $hostname, $mac, $description, $noerr) = @_;
98 die "please implement inside plugin";
102 my ($class, $plugin_config, $subnetid, $subnet, $ip, $noerr) = @_;
104 die "please implement inside plugin";
108 my ($class, $plugin_config) = @_;