File Coverage

blib/lib/Linux/Virt/Plugin.pm
Criterion Covered Total %
statement 25 53 47.1
branch n/a
condition n/a
subroutine 9 20 45.0
pod n/a
total 34 73 46.5


line stmt bran cond sub pod time code
1             package Linux::Virt::Plugin;
2             {
3             $Linux::Virt::Plugin::VERSION = '0.15';
4             }
5             BEGIN {
6 1     1   2072 $Linux::Virt::Plugin::AUTHORITY = 'cpan:TEX';
7             }
8             # ABSTRACT: baseclass for an Linux::Virt plugin
9              
10 1     1   23 use 5.010_000;
  1         3  
  1         37  
11 1     1   6 use mro 'c3';
  1         2  
  1         8  
12 1     1   29 use feature ':5.10';
  1         2  
  1         117  
13              
14 1     1   6 use Moose;
  1         2  
  1         8  
15 1     1   6021 use namespace::autoclean;
  1         12  
  1         9  
16              
17             # use IO::Handle;
18             # use autodie;
19             # use MooseX::Params::Validate;
20             # use Carp;
21             # use English qw( -no_match_vars );
22             # use Try::Tiny;
23              
24 1     1   1024 use Sys::FS;
  1         236343  
  1         47  
25 1     1   12 use Sys::Run;
  1         2  
  1         499  
26              
27             # extends ...
28             # has ...
29             has 'sys' => (
30             'is' => 'rw',
31             'isa' => 'Sys::Run',
32             'lazy' => 1,
33             'builder' => '_init_sys',
34             );
35              
36             has 'fs' => (
37             'is' => 'rw',
38             'isa' => 'Sys::FS',
39             'lazy' => 1,
40             'builder' => '_init_fs',
41             );
42              
43             has 'priority' => (
44             'is' => 'ro',
45             'isa' => 'Int',
46             'lazy' => 1,
47             'builder' => '_init_priority',
48             );
49             # with ...
50             with qw(Config::Yak::RequiredConfig Log::Tree::RequiredLogger);
51             # initializers ...
52 0     0     sub _init_priority { return 0; }
53              
54             sub _init_sys {
55 0     0     my $self = shift;
56              
57 0           my $Sys = Sys::Run::->new( { 'logger' => $self->logger(), } );
58              
59 0           return $Sys;
60             } ## end sub _init_sys
61              
62             sub _init_fs {
63 0     0     my $self = shift;
64              
65 0           my $FS = Sys::FS::->new(
66             {
67             'logger' => $self->logger(),
68             'sys' => $self->sys(),
69             }
70             );
71              
72 0           return $FS;
73             } ## end sub _init_fs
74              
75             # your code here ...
76             sub is_host {
77 0     0     my $self = shift;
78              
79 0           return;
80             }
81              
82             sub is_vm {
83 0     0     my $self = shift;
84              
85 0           return;
86             }
87              
88             sub is_running {
89 0     0     my $self = shift;
90              
91 0           return;
92             }
93              
94             sub create {
95 0     0     my $self = shift;
96              
97 0           warn "This method is not implemented in this baseclass.\n";
98              
99 0           return;
100             } ## end sub create
101              
102             ## no critic (ProhibitBuiltinHomonyms)
103             sub delete {
104             ## use critic
105 0     0     my $self = shift;
106              
107 0           warn "This method is not implemented in this baseclcass.\n";
108              
109 0           return;
110             } ## end sub delete
111              
112             sub vms {
113 0     0     my $self = shift;
114              
115 0           warn "This method is not implemented in this baseclcass.\n";
116              
117 0           return;
118             } ## end sub vms
119              
120             sub start {
121 0     0     my $self = shift;
122              
123 0           warn "This method is not implemented in this baseclcass.\n";
124              
125 0           return;
126             } ## end sub start
127              
128             sub stop {
129 0     0     my $self = shift;
130              
131 0           warn "This method is not implemented in this baseclcass.\n";
132              
133 0           return;
134             } ## end sub stop
135              
136 1     1   8 no Moose;
  1         2  
  1         8  
137             __PACKAGE__->meta->make_immutable;
138              
139             1;
140              
141             __END__
142              
143             =pod
144              
145             =encoding utf-8
146              
147             =head1 NAME
148              
149             Linux::Virt::Plugin - baseclass for an Linux::Virt plugin
150              
151             =head1 DESCRIPTION
152              
153             This module is a base class for all Linux::Virt plugins.
154              
155             =head1 METHODS
156              
157             =head2 create
158              
159             Create a new VM. Subclasses should implement this method.
160              
161             =head2 delete
162              
163             Delete an existing VM. Subclasses should implement this method.
164              
165             =head2 is_host
166              
167             Returns a true value is this system is a (physical) host and able to run
168             VMs of this type. Subclasses should implement this method.
169              
170             =head2 is_running
171              
172             Returns true if the given VM is currently running.
173              
174             =head2 is_vm
175              
176             Returns true if this method is called within an VM. Subclasses should implement this method.
177              
178             =head2 start
179              
180             Start an existing VM. Subclasses should implement this method.
181              
182             =head2 stop
183              
184             Shutdown an existing VM. Subclasses should implement this method.
185              
186             =head2 vms
187              
188             List all available VMs. Subclasses should implement this method.
189              
190             =head1 NAME
191              
192             Linux::Virt::Plugin - Base class for all Linux::Virt plugins.
193              
194             =head1 AUTHOR
195              
196             Dominik Schulz <dominik.schulz@gauner.org>
197              
198             =head1 COPYRIGHT AND LICENSE
199              
200             This software is copyright (c) 2012 by Dominik Schulz.
201              
202             This is free software; you can redistribute it and/or modify it under
203             the same terms as the Perl 5 programming language system itself.
204              
205             =cut