File Coverage

blib/lib/Lim/Plugin/DNS.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Lim::Plugin::DNS;
2              
3 1     1   25606 use common::sense;
  1         11  
  1         6  
4              
5 1     1   65 use base qw(Lim::Component);
  1         2  
  1         774  
6              
7             =encoding utf8
8              
9             =head1 NAME
10              
11             Lim::Plugin::DNS - DNS Manager plugin for Lim
12              
13             =head1 VERSION
14              
15             Version 0.12
16              
17             =cut
18              
19             our $VERSION = '0.12';
20              
21             =head1 SYNOPSIS
22              
23             use Lim::Plugin::DNS;
24              
25             # Create a Server object
26             $server = Lim::Plugin::DNS->Server;
27              
28             # Create a Client object
29             $client = Lim::Plugin::DNS->Client;
30              
31             # Create a CLI object
32             $cli = Lim::Plugin::DNS->CLI;
33              
34             =head1 DESCRIPTION
35              
36             This plugin manage generic DNS related information like zone files via Lim. It
37             does not manage DNS software specific information.
38              
39             =head1 METHODS
40              
41             =over 4
42              
43             =item $plugin_name = Lim::Plugin::DNS->Name
44              
45             Returns the plugin's name.
46              
47             =cut
48              
49             sub Name {
50             'DNS';
51             }
52              
53             =item $plugin_description = Lim::Plugin::DNS->Description
54              
55             Returns the plugin's description.
56              
57             =cut
58              
59             sub Description {
60             'This plugin manage generic DNS related information like zone files via Lim. It does not manage DNS software specific information.';
61             }
62              
63             =item $call_hash_ref = Lim::Plugin::DNS->Calls
64              
65             Returns a hash reference to the calls that can be made to this plugin, used both
66             in Server and Client to verify input and output arguments.
67              
68             See CALLS for list of calls and arguments.
69              
70             =cut
71              
72             sub Calls {
73             {
74             ReadZones => {
75             out => {
76             zone => {
77             file => 'string',
78             software => 'string optional',
79             read => 'bool',
80             write => 'bool'
81             }
82             }
83             },
84             #
85             # Zone
86             #
87             CreateZone => {
88             in => {
89             zone => {
90             '' => 'required',
91             file => 'string',
92             software => 'string optional',
93             option => {
94             name => 'string',
95             value => 'string'
96             },
97             rr => {
98             name => 'string',
99             ttl => 'string optional',
100             class => 'string optional',
101             type => 'string',
102             rdata => 'string',
103             rr => {
104             ttl => 'string optional',
105             class => 'string optional',
106             type => 'string',
107             rdata => 'string'
108             }
109             },
110             content => 'string optional'
111             }
112             },
113             },
114             ReadZone => {
115             in => {
116             zone => {
117             '' => 'required',
118             file => 'string',
119             software => 'string optional',
120             as_content => 'bool optional'
121             }
122             },
123             out => {
124             zone => {
125             file => 'string',
126             software => 'string optional',
127             option => {
128             name => 'string',
129             value => 'string'
130             },
131             rr => {
132             name => 'string',
133             ttl => 'string optional',
134             class => 'string optional',
135             type => 'string',
136             rdata => 'string'
137             },
138             content => 'string optional'
139             }
140             }
141             },
142             UpdateZone => {
143             in => {
144             zone => {
145             '' => 'required',
146             file => 'string',
147             software => 'string optional',
148             option => {
149             name => 'string',
150             value => 'string'
151             },
152             rr => {
153             name => 'string',
154             ttl => 'string optional',
155             class => 'string optional',
156             type => 'string',
157             rdata => 'string',
158             rr => {
159             ttl => 'string optional',
160             class => 'string optional',
161             type => 'string',
162             rdata => 'string'
163             }
164             },
165             content => 'string optional'
166             }
167             }
168             },
169             DeleteZone => {
170             in => {
171             zone => {
172             '' => 'required',
173             file => 'string',
174             software => 'string optional'
175             }
176             }
177             },
178             #
179             # Zone Option
180             #
181             CreateZoneOption => {
182             in => {
183             zone => {
184             '' => 'required',
185             file => 'string',
186             software => 'string optional',
187             option => {
188             '' => 'required',
189             name => 'string',
190             value => 'string'
191             }
192             }
193             }
194             },
195             ReadZoneOption => {
196             in => {
197             zone => {
198             '' => 'required',
199             file => 'string',
200             software => 'string optional',
201             option => {
202             name => 'string'
203             }
204             }
205             },
206             out => {
207             zone => {
208             file => 'string',
209             software => 'string optional',
210             option => {
211             name => 'string',
212             value => 'string'
213             }
214             }
215             }
216             },
217             UpdateZoneOption => {
218             in => {
219             zone => {
220             '' => 'required',
221             file => 'string',
222             software => 'string optional',
223             option => {
224             '' => 'required',
225             name => 'string',
226             value => 'string'
227             }
228             }
229             }
230             },
231             DeleteZoneOption => {
232             in => {
233             zone => {
234             '' => 'required',
235             file => 'string',
236             software => 'string optional',
237             option => {
238             '' => 'required',
239             name => 'string'
240             }
241             }
242             }
243             },
244             #
245             # Zone Resource Record
246             #
247             CreateZoneRr => {
248             in => {
249             zone => {
250             '' => 'required',
251             file => 'string',
252             software => 'string optional',
253             rr => {
254             '' => 'required',
255             name => 'string',
256             ttl => 'string optional',
257             class => 'string optional',
258             type => 'string',
259             rdata => 'string',
260             rr => {
261             ttl => 'string optional',
262             class => 'string optional',
263             type => 'string',
264             rdata => 'string'
265             }
266             }
267             }
268             }
269             },
270             ReadZoneRr => {
271             in => {
272             zone => {
273             '' => 'required',
274             file => 'string',
275             software => 'string optional',
276             rr => {
277             name => 'string'
278             }
279             }
280             },
281             out => {
282             zone => {
283             file => 'string',
284             software => 'string optional',
285             rr => {
286             name => 'string',
287             ttl => 'string optional',
288             class => 'string optional',
289             type => 'string',
290             rdata => 'string'
291             }
292             }
293             }
294             },
295             UpdateZoneRr => {
296             in => {
297             zone => {
298             '' => 'required',
299             file => 'string',
300             software => 'string optional',
301             rr => {
302             '' => 'required',
303             name => 'string',
304             ttl => 'string optional',
305             class => 'string optional',
306             type => 'string',
307             rdata => 'string',
308             rr => {
309             ttl => 'string optional',
310             class => 'string optional',
311             type => 'string',
312             rdata => 'string'
313             }
314             }
315             }
316             }
317             },
318             DeleteZoneRr => {
319             in => {
320             zone => {
321             '' => 'required',
322             file => 'string',
323             software => 'string optional',
324             rr => {
325             '' => 'required',
326             name => 'string'
327             }
328             }
329             }
330             }
331             };
332             }
333              
334             =item $command_hash_ref = Lim::Plugin::DNS->Commands
335              
336             Returns a hash reference to the CLI commands that can be made by this plugin.
337              
338             See COMMANDS for list of commands and arguments.
339              
340             =cut
341              
342             sub Commands {
343             {
344             zones => [ 'List existing zones and related software' ],
345             zone => {
346             create => [ '[--software ] ', 'Create a new zone with the content of a local zone file' ],
347             read => [ '[--software ] ', 'Read zones and display content' ],
348             update => [ '[--software ] ', 'Update a existing zone with the content of a local zone file' ],
349             delete => [ '[--software ] ', 'Delete the specified zone' ]
350             },
351             option => {
352             create => [ '[--software ]
353             read => [ '[--software ] [option name]', 'Read and display the specified option, or all if not given, from the zone' ],
354             update => [ '[--software ]
355             delete => [ '[--software ]
356             },
357             rr => {
358             create => [ '[--software ] [--ttl ] [--class ] ', 'Create a new resource record in an existing zone' ],
359             read => [ '[--software ] [rr name]', 'Read and display the specified resource record, or all if not given, from the zone' ],
360             update => [ '[--software ] [--ttl ] [--class ] ', 'Update an existing resource record in a zone' ],
361             delete => [ '[--software ] ', 'Delete the specified resource record from a zone' ]
362             }
363             };
364             }
365              
366             =back
367              
368             =head1 CALLS
369              
370             See L on how calls and callback functions should be
371             used.
372              
373             =over 4
374              
375             =item $client->ReadZones(sub { my ($call, $response) = @_; })
376              
377             Get a list of all zones that can be managed by the plugin.
378              
379             $response = {
380             zone => # (optional) Single hash or an array of hashes as below:
381             {
382             file => 'string', # Full path to zone file
383             software => 'string', # Software related to the zone file (optional)
384             read => 'bool', # True if file can be read, otherwise false
385             write => 'bool', # True if file can be written to, otherwise false
386             }
387             };
388              
389             =item $client->CreateZone($input, sub { my ($call) = @_; })
390              
391             Create a new zone file, returns an error if it failed to create the zone file
392             otherwise there is no response.
393              
394             $input = {
395             zone => # Single hash or an array of hashes as below:
396             {
397             file => 'string', # Full path to zone file or relative path when used
398             # with software
399             software => 'string', # Software to create zone file in, must be used if
400             # file is relative path (optional)
401              
402             # Zone file data is created by option and rr or by a single content
403              
404             option => # (optional) Single hash or an array of hashes as below:
405             {
406             name => 'string', # Name of option (without $)
407             value => 'string' # Value of option
408             },
409             rr => # (optional) Single hash or an array of hashes as below:
410             {
411             name => 'string', # Name of RR
412             ttl => 'string', # TTL of RR (optional)
413             class => 'string', # Class of RR (optional)
414             type => 'string', # Type of RR
415             rdata => 'string', # Rdata of RR
416              
417             # If you wish to add more RR to the same name you can specify more rr
418             # inside the rr.
419            
420             rr => # (optional) Single hash or an array of hashes as below:
421             {
422             ttl => 'string', # TTL of RR (optional)
423             class => 'string', # Class of RR (optional)
424             type => 'string', # Type of RR
425             rdata => 'string', # Rdata of RR
426             }
427             },
428             content => 'string' # Content of zone file (optional)
429             }
430             };
431              
432             =item $client->ReadZone($input, sub { my ($call, $response) = @_; })
433              
434             Returns a zone file as a content or split into option and rr.
435              
436             $input = {
437             zone => # Single hash or an array of hashes as below:
438             {
439             file => 'string', # Full path to zone file or relative path when used
440             # with software
441             software => 'string', # Software to create zone file in, must be used if
442             # file is relative path (optional)
443             as_content => 'bool' # Specify that content should be returned (optional)
444             }
445             };
446              
447             $response = {
448             zone => # (optional) Single hash or an array of hashes as below:
449             {
450             file => 'string', # Full path to zone file
451             software => 'string', # Software related to the zone file (optional)
452             option => # (optional) Single hash or an array of hashes as below:
453             {
454             name => 'string', # Name of option (without $)
455             value => 'string' # Value of option
456             },
457             rr => # (optional) Single hash or an array of hashes as below:
458             {
459             name => 'string', # Name of RR
460             ttl => 'string', # TTL of RR (optional)
461             class => 'string', # Class of RR (optional)
462             type => 'string', # Type of RR
463             rdata => 'string', # Rdata of RR
464             },
465             content => 'string' # Content of zone file (optional)
466             }
467             };
468              
469             =item $client->UpdateZone($input, sub { my ($call) = @_; })
470              
471             Update a zone file, this overwrites all zone data. Returns an error if it failed
472             to update the zone file otherwise there is no reponse.
473              
474             $input = {
475             zone => # Single hash or an array of hashes as below:
476             {
477             file => 'string', # Full path to zone file or relative path when used
478             # with software
479             software => 'string', # Software to create zone file in, must be used if
480             # file is relative path (optional)
481              
482             # Zone file data is created by option and rr or by a single content
483              
484             option => # (optional) Single hash or an array of hashes as below:
485             {
486             name => 'string', # Name of option (without $)
487             value => 'string' # Value of option
488             },
489             rr => # (optional) Single hash or an array of hashes as below:
490             {
491             name => 'string', # Name of RR
492             ttl => 'string', # TTL of RR (optional)
493             class => 'string', # Class of RR (optional)
494             type => 'string', # Type of RR
495             rdata => 'string', # Rdata of RR
496              
497             # If you wish to add more RR to the same name you can specify more rr
498             # inside the rr.
499            
500             rr => # (optional) Single hash or an array of hashes as below:
501             {
502             ttl => 'string', # TTL of RR (optional)
503             class => 'string', # Class of RR (optional)
504             type => 'string', # Type of RR
505             rdata => 'string', # Rdata of RR
506             }
507             },
508             content => 'string' # Content of zone file (optional)
509             }
510             };
511              
512             =item $client->DeleteZone($input, sub { my ($call) = @_; })
513              
514             Delete a zone file, returns an error if it failed to delete the zone file
515             otherwise there is no reponse.
516              
517             $input = {
518             zone => # Single hash or an array of hashes as below:
519             {
520             file => 'string', # Full path to zone file or relative path when used
521             # with software
522             software => 'string', # Software to create zone file in, must be used if
523             # file is relative path (optional)
524             }
525             };
526              
527             =item $client->CreateZoneOption($input, sub { my ($call) = @_; })
528              
529             Create a new zone option, returns an error if it failed to create the zone
530             option otherwise there is no reponse.
531              
532             $input = {
533             zone => # Single hash or an array of hashes as below:
534             {
535             file => 'string', # Full path to zone file or relative path when used
536             # with software
537             software => 'string', # Software to create zone file in, must be used if
538             # file is relative path (optional)
539              
540             option => # Single hash or an array of hashes as below:
541             {
542             name => 'string', # Name of option (without $)
543             value => 'string' # Value of option
544             }
545             }
546             };
547              
548             =item $client->ReadZoneOption($input, sub { my ($call, $response) = @_; })
549              
550             Return zone options specified or all zone options for a zone file.
551              
552             $input = {
553             zone => # Single hash or an array of hashes as below:
554             {
555             file => 'string', # Full path to zone file or relative path when used
556             # with software
557             software => 'string', # Software to create zone file in, must be used if
558             # file is relative path (optional)
559              
560             option => # (optional) Single hash or an array of hashes as below:
561             {
562             name => 'string' # Name of option (without $)
563             }
564             }
565             };
566              
567             $response = {
568             zone => # (optional) Single hash or an array of hashes as below:
569             {
570             file => 'string', # Full path to zone file
571             software => 'string', # Software related to the zone file (optional)
572             option => # (optional) Single hash or an array of hashes as below:
573             {
574             name => 'string', # Name of option (without $)
575             value => 'string' # Value of option
576             }
577             }
578             };
579              
580             =item $client->UpdateZoneOption($input, sub { my ($call) = @_; })
581              
582             Update a zone option, this does not overwrite other zone options. Returns an
583             error if it failed to update the zone options otherwise there is no reponse.
584              
585             $input = {
586             zone => # Single hash or an array of hashes as below:
587             {
588             file => 'string', # Full path to zone file or relative path when used
589             # with software
590             software => 'string', # Software to create zone file in, must be used if
591             # file is relative path (optional)
592              
593             option => # Single hash or an array of hashes as below:
594             {
595             name => 'string', # Name of option (without $)
596             value => 'string' # Value of option
597             }
598             }
599             };
600              
601             =item $client->DeleteZoneOption($input, sub { my ($call) = @_; })
602              
603             Delete a zone options, returns an error if it failed to delete the zone options
604             otherwise there is no reponse.
605              
606             $input = {
607             zone => # Single hash or an array of hashes as below:
608             {
609             file => 'string', # Full path to zone file or relative path when used
610             # with software
611             software => 'string', # Software to create zone file in, must be used if
612             # file is relative path (optional)
613              
614             option => # Single hash or an array of hashes as below:
615             {
616             name => 'string' # Name of option (without $)
617             }
618             }
619             };
620              
621             =item $client->CreateZoneRr($input, sub { my ($call) = @_; })
622              
623             Create a new zone resource record, returns an error if it failed to create the
624             zone resource record otherwise there is no reponse.
625              
626             $input = {
627             zone => # Single hash or an array of hashes as below:
628             {
629             file => 'string', # Full path to zone file or relative path when used
630             # with software
631             software => 'string', # Software to create zone file in, must be used if
632             # file is relative path (optional)
633              
634             rr => # Single hash or an array of hashes as below:
635             {
636             name => 'string', # Name of RR
637             ttl => 'string', # TTL of RR (optional)
638             class => 'string', # Class of RR (optional)
639             type => 'string', # Type of RR
640             rdata => 'string', # Rdata of RR
641              
642             # If you wish to add more RR to the same name you can specify more rr
643             # inside the rr.
644            
645             rr => # (optional) Single hash or an array of hashes as below:
646             {
647             ttl => 'string', # TTL of RR (optional)
648             class => 'string', # Class of RR (optional)
649             type => 'string', # Type of RR
650             rdata => 'string', # Rdata of RR
651             }
652             }
653             }
654             };
655              
656             =item $client->ReadZoneRr($input, sub { my ($call, $response) = @_; })
657              
658             Return zone resource records specified or all zone resource records for a zone
659             file.
660              
661             $input = {
662             zone => # Single hash or an array of hashes as below:
663             {
664             file => 'string', # Full path to zone file or relative path when used
665             # with software
666             software => 'string', # Software to create zone file in, must be used if
667             # file is relative path (optional)
668              
669             rr => # (optional) Single hash or an array of hashes as below:
670             {
671             name => 'string' # Name of RR
672             }
673             }
674             };
675              
676             $response = {
677             zone => # (optional) Single hash or an array of hashes as below:
678             {
679             file => 'string', # Full path to zone file
680             software => 'string', # Software related to the zone file (optional)
681             rr => # (optional) Single hash or an array of hashes as below:
682             {
683             name => 'string', # Name of RR
684             ttl => 'string', # TTL of RR (optional)
685             class => 'string', # Class of RR (optional)
686             type => 'string', # Type of RR
687             rdata => 'string', # Rdata of RR
688             }
689             }
690             };
691              
692             =item $client->UpdateZoneRr($input, sub { my ($call) = @_; })
693              
694             Update a zone resource record, this does not remove other zone resource records.
695             Returns an error if it failed to update the zone resource record otherwise there
696             is no reponse.
697              
698             $input = {
699             zone => # Single hash or an array of hashes as below:
700             {
701             file => 'string', # Full path to zone file or relative path when used
702             # with software
703             software => 'string', # Software to create zone file in, must be used if
704             # file is relative path (optional)
705              
706             rr => # Single hash or an array of hashes as below:
707             {
708             name => 'string', # Name of RR
709             ttl => 'string', # TTL of RR (optional)
710             class => 'string', # Class of RR (optional)
711             type => 'string', # Type of RR
712             rdata => 'string', # Rdata of RR
713              
714             # If you wish to add more RR to the same name you can specify more rr
715             # inside the rr.
716            
717             rr => # (optional) Single hash or an array of hashes as below:
718             {
719             ttl => 'string', # TTL of RR (optional)
720             class => 'string', # Class of RR (optional)
721             type => 'string', # Type of RR
722             rdata => 'string', # Rdata of RR
723             }
724             }
725             }
726             };
727              
728             =item $client->DeleteZoneRr($input, sub { my ($call) = @_; })
729              
730             Delete a zone resource records, returns an error if it failed to delete the zone
731             resource record otherwise there is no reponse.
732              
733             $input = {
734             zone => # Single hash or an array of hashes as below:
735             {
736             file => 'string', # Full path to zone file or relative path when used
737             # with software
738             software => 'string', # Software to create zone file in, must be used if
739             # file is relative path (optional)
740              
741             rr => # Single hash or an array of hashes as below:
742             {
743             name => 'string' # Name of RR
744             }
745             }
746             };
747              
748             =back
749              
750             =head1 COMMANDS
751              
752             =over 4
753              
754             =item zones
755              
756             List existing zones and related software.
757              
758             =item zone create [--software ]
759              
760             Create a new zone with the content of a local zone file.
761              
762             =item zone read [--software ]
763              
764             Read zones and display content.
765              
766             =item zone update [--software ]
767              
768             Update a existing zone with the content of a local zone file.
769              
770             =item zone delete [--software ]
771              
772             Delete the specified zone.
773              
774             =item option create [--software ]
775              
776             Create a new zone option in the an existing zone.
777              
778             =item option read [--software ] [option name]
779              
780             Read and display the specified option, or all if not given, from the zone.
781              
782             =item option update [--software ]
783              
784             Update an existing option in a zone.
785              
786             =item option delete [--software ]
787              
788             Delete the specified option from a zone.
789              
790             =item rr create [--software ] [--ttl ] [--class ]
791              
792             Create a new resource record in an existing zone.
793              
794             =item rr read [--software ] [rr name]
795              
796             Read and display the specified resource record, or all if not given, from the zone.
797              
798             =item rr update [--software ] [--ttl ] [--class ]
799              
800             Update an existing resource record in a zone.
801              
802             =item rr delete [--software ]
803              
804             Delete the specified resource record from a zone.
805              
806             =back
807              
808             =head1 AUTHOR
809              
810             Jerry Lundström, C<< >>
811              
812             =head1 BUGS
813              
814             Please report any bugs or feature requests to L.
815              
816             =head1 SUPPORT
817              
818             You can find documentation for this module with the perldoc command.
819              
820             perldoc Lim::Plugin::DNS
821              
822             You can also look for information at:
823              
824             =over 4
825              
826             =item * Lim issue tracker (report bugs here)
827              
828             L
829              
830             =back
831              
832             =head1 ACKNOWLEDGEMENTS
833              
834             =head1 LICENSE AND COPYRIGHT
835              
836             Copyright 2012-2013 Jerry Lundström.
837              
838             This program is free software; you can redistribute it and/or modify it
839             under the terms of either: the GNU General Public License as published
840             by the Free Software Foundation; or the Artistic License.
841              
842             See http://dev.perl.org/licenses/ for more information.
843              
844              
845             =cut
846              
847             1; # End of Lim::Plugin::DNS