Debian Codegraph @

lib/Sys/Virt/NWFilter.pm

raw
1 # -*- perl -*-
2 #
3 # Copyright (C) 2006 Red Hat
4 # Copyright (C) 2006-2007 Daniel P. Berrange
5 #
6 # This program is free software; You can redistribute it and/or modify
7 # it under either:
8 #
9 # a) the GNU General Public License as published by the Free
10 # Software Foundation; either version 2, or (at your option) any
11 # later version,
12 #
13 # or
14 #
15 # b) the "Artistic License"
16 #
17 # The file "LICENSE" distributed along with this file provides full
18 # details of the terms and conditions of the two licenses.
19
20 =pod
21
22 =head1 NAME
23
24 Sys::Virt::NWFilter - Represent & manage a libvirt virtual network
25
26 =head1 DESCRIPTION
27
28 The C<Sys::Virt::NWFilter> module represents a virtual network managed
29 by the virtual machine monitor.
30
31 =head1 METHODS
32
33 =over 4
34
35 =cut
36
37 package Sys::Virt::NWFilter;
38
39 use strict;
40 use warnings;
41
42
43 sub _new {
44 my $proto = shift;
45 my $class = ref($proto) || $proto;
46 my %params = @_;
47
48 my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
49 my $self;
50 if (exists $params{name}) {
51 $self = Sys::Virt::NWFilter::_lookup_by_name($con, $params{name});
52 } elsif (exists $params{uuid}) {
53 if (length($params{uuid}) == 16) {
54 $self = Sys::Virt::NWFilter::_lookup_by_uuid($con, $params{uuid});
55 } elsif (length($params{uuid}) == 32 ||
56 length($params{uuid}) == 36) {
57 $self = Sys::Virt::NWFilter::_lookup_by_uuid_string($con, $params{uuid});
58 } else {
59 die "UUID must be either 16 unsigned bytes, or 32/36 hex characters long";
60 }
61 } elsif (exists $params{xml}) {
62 $self = Sys::Virt::NWFilter::_define_xml($con, $params{xml}, $params{flags});
63 } else {
64 die "address, id or uuid parameters are required";
65 }
66
67 bless $self, $class;
68
69 return $self;
70 }
71
72
73 =item my $uuid = $filter->get_uuid()
74
75 Returns a 16 byte long string containing the raw globally unique identifier
76 (UUID) for the network.
77
78 =item my $uuid = $filter->get_uuid_string()
79
80 Returns a printable string representation of the raw UUID, in the format
81 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'.
82
83 =item my $name = $filter->get_name()
84
85 Returns a string with a locally unique name of the network
86
87 =item my $xml = $filter->get_xml_description()
88
89 Returns an XML document containing a complete description of
90 the network's configuration
91
92 =item $filter->undefine()
93
94 Remove the configuration associated with a network filter previously defined
95 with the C<define_nwfilter> method in L<Sys::Virt>.
96
97 =back
98
99 =head1 CONSTANTS
100
101 This section documents constants that are used with various
102 APIs described above
103
104 =head2 NWFILTER DEFINE
105
106 The following constants can be used to control the behaviour
107 of network filter define operations
108
109 =over 4
110
111 =item Sys::Virt::NWFilter::DEFINE_VALIDATE
112
113 Validate the XML document against the XML schema
114
115 =cut
116
117
118 1;
119
120 =back
121
122 =head1 AUTHORS
123
124 Daniel P. Berrange <[email protected]>
125
126 =head1 COPYRIGHT
127
128 Copyright (C) 2006 Red Hat
129 Copyright (C) 2006-2007 Daniel P. Berrange
130
131 =head1 LICENSE
132
133 This program is free software; you can redistribute it and/or modify
134 it under the terms of either the GNU General Public License as published
135 by the Free Software Foundation (either version 2 of the License, or at
136 your option any later version), or, the Artistic License, as specified
137 in the Perl README file.
138
139 =head1 SEE ALSO
140
141 L<Sys::Virt>, L<Sys::Virt::Error>, C<http://libvirt.org>
142
143 =cut