perl-Sys-Virt/SOURCES/0000-Add-NWFilterBinding.pm...

127 lines
3.0 KiB
Diff

From d5ae3d1db19b52676489c2312efd21ab5e86aee4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Tue, 14 Aug 2018 11:46:08 +0100
Subject: [PATCH] Add NWFilterBinding.pm module missed in dist
---
lib/Sys/Virt/NWFilterBinding.pm | 107 ++++++++++++++++++++++++++++++++
1 file changed, 107 insertions(+)
create mode 100644 lib/Sys/Virt/NWFilterBinding.pm
diff --git a/lib/Sys/Virt/NWFilterBinding.pm b/lib/Sys/Virt/NWFilterBinding.pm
new file mode 100644
index 0000000..2c56b3f
--- /dev/null
+++ b/lib/Sys/Virt/NWFilterBinding.pm
@@ -0,0 +1,107 @@
+# -*- perl -*-
+#
+# Copyright (C) 2018 Red Hat
+#
+# This program is free software; You can redistribute it and/or modify
+# it under either:
+#
+# a) the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version,
+#
+# or
+#
+# b) the "Artistic License"
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions of the two licenses.
+
+=pod
+
+=head1 NAME
+
+Sys::Virt::NWFilterBinding - Represent & manage a network filter binding
+
+=head1 DESCRIPTION
+
+The C<Sys::Virt::NWFilterBinding> module represents a binding between a
+network filter and a network port device.
+
+=head1 METHODS
+
+=over 4
+
+=cut
+
+package Sys::Virt::NWFilterBinding;
+
+use strict;
+use warnings;
+
+
+sub _new {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my %params = @_;
+
+ my $con = exists $params{connection} ? $params{connection} : die "connection parameter is required";
+ my $self;
+ if (exists $params{portdev}) {
+ $self = Sys::Virt::NWFilterBinding::_lookup_by_port_dev($con, $params{portdev});
+ } elsif (exists $params{xml}) {
+ $self = Sys::Virt::NWFilterBinding::_create_xml($con, $params{xml});
+ } else {
+ die "portdev or xml parameters are required";
+ }
+
+ bless $self, $class;
+
+ return $self;
+}
+
+
+=item my $name = $binding->get_port_dev()
+
+Returns a string with the name of the network port device that is bound to
+
+=item my $name = $binding->get_filter_name()
+
+Returns a string with the name of the network filter that is bound to
+
+=item my $xml = $binding->get_xml_description()
+
+Returns an XML document containing a complete description of
+the network's configuration
+
+=item $binding->delete()
+
+Unbind the network port device from the filter
+
+=cut
+
+
+1;
+
+=back
+
+=head1 AUTHORS
+
+Daniel P. Berrange <berrange@redhat.com>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2018 Red Hat
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of either the GNU General Public License as published
+by the Free Software Foundation (either version 2 of the License, or at
+your option any later version), or, the Artistic License, as specified
+in the Perl README file.
+
+=head1 SEE ALSO
+
+L<Sys::Virt>, L<Sys::Virt::Error>, C<http://libvirt.org>
+
+=cut
--
2.17.1