]> git.proxmox.com Git - pve-network.git/blame - PVE/Network/SDN/Dns/Plugin.pm
dns/ipam : move api_request helper to sdn module
[pve-network.git] / PVE / Network / SDN / Dns / Plugin.pm
CommitLineData
ee4f339e
AD
1package PVE::Network::SDN::Dns::Plugin;
2
3use strict;
4use warnings;
5
6use PVE::Tools qw(run_command);
7use PVE::JSONSchema;
8use PVE::Cluster;
9use HTTP::Request;
10use LWP::UserAgent;
ee4f339e
AD
11
12use Data::Dumper;
13use PVE::JSONSchema qw(get_standard_option);
14use base qw(PVE::SectionConfig);
15
16PVE::Cluster::cfs_register_file('sdn/dns.cfg',
17 sub { __PACKAGE__->parse_config(@_); },
18 sub { __PACKAGE__->write_config(@_); });
19
20PVE::JSONSchema::register_standard_option('pve-sdn-dns-id', {
21 description => "The SDN dns object identifier.",
22 type => 'string', format => 'pve-sdn-dns-id',
23});
24
25PVE::JSONSchema::register_format('pve-sdn-dns-id', \&parse_sdn_dns_id);
26sub parse_sdn_dns_id {
27 my ($id, $noerr) = @_;
28
29 if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
30 return undef if $noerr;
31 die "dns ID '$id' contains illegal characters\n";
32 }
33 return $id;
34}
35
36my $defaultData = {
37
38 propertyList => {
39 type => {
40 description => "Plugin type.",
41 type => 'string', format => 'pve-configid',
42 },
43 ttl => { type => 'integer', optional => 1 },
4ad78442 44 reversev6mask => { type => 'integer', optional => 1 },
ee4f339e
AD
45 dns => get_standard_option('pve-sdn-dns-id',
46 { completion => \&PVE::Network::SDN::Dns::complete_sdn_dns }),
47 },
48};
49
50sub private {
51 return $defaultData;
52}
53
54sub parse_section_header {
55 my ($class, $line) = @_;
56
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); };
61 $errmsg = $@ if $@;
62 my $config = {}; # to return additional attributes
63 return ($type, $id, $errmsg, $config);
64 }
65 return undef;
66}
67
68
69sub add_a_record {
70 my ($class, $plugin_config, $type, $zone, $reversezone, $hostname, $ip) = @_;
71}
72
73sub del_a_record {
74 my ($class, $plugin_config, $hostname, $ip) = @_;
75}
76
77sub on_update_hook {
78 my ($class, $plugin_config) = @_;
79}
80
ee4f339e 811;