]>
Commit | Line | Data |
---|---|---|
ee4f339e AD |
1 | package PVE::Network::SDN::Dns::Plugin; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use PVE::Tools qw(run_command); | |
7 | use PVE::JSONSchema; | |
8 | use PVE::Cluster; | |
9 | use HTTP::Request; | |
10 | use LWP::UserAgent; | |
ee4f339e AD |
11 | |
12 | use Data::Dumper; | |
13 | use PVE::JSONSchema qw(get_standard_option); | |
14 | use base qw(PVE::SectionConfig); | |
15 | ||
16 | PVE::Cluster::cfs_register_file('sdn/dns.cfg', | |
17 | sub { __PACKAGE__->parse_config(@_); }, | |
18 | sub { __PACKAGE__->write_config(@_); }); | |
19 | ||
20 | PVE::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 | ||
25 | PVE::JSONSchema::register_format('pve-sdn-dns-id', \&parse_sdn_dns_id); | |
26 | sub 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 | ||
36 | my $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 | ||
50 | sub private { | |
51 | return $defaultData; | |
52 | } | |
53 | ||
54 | sub 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 | ||
69 | sub add_a_record { | |
70 | my ($class, $plugin_config, $type, $zone, $reversezone, $hostname, $ip) = @_; | |
71 | } | |
72 | ||
73 | sub del_a_record { | |
74 | my ($class, $plugin_config, $hostname, $ip) = @_; | |
75 | } | |
76 | ||
77 | sub on_update_hook { | |
78 | my ($class, $plugin_config) = @_; | |
79 | } | |
80 | ||
ee4f339e | 81 | 1; |