1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# NFS.pm
# - provides NFS-specific overrides of the OpenSLX::OSExport::ExportType API.
#
# (c) 2006 - OpenSLX.com
#
# Oliver Tappe <ot@openslx.com>
#
package OpenSLX::OSExport::ExportType::NFS;
use vars qw(@ISA $VERSION);
@ISA = ('OpenSLX::OSExport::ExportType::Base');
$VERSION = 1.01; # API-version . implementation-version
use strict;
use Carp;
use File::Basename;
use OpenSLX::Basics;
use OpenSLX::Utils;
use OpenSLX::OSExport::ExportType::Base 1.01;
################################################################################
### interface methods
################################################################################
sub new
{
my $class = shift;
my $self = {
'name' => 'NFS',
};
return bless $self, $class;
}
sub initialize
{
my $self = shift;
my $engine = shift;
$self->SUPER::initialize($engine);
}
sub exportVendorOS
{
my $self = shift;
my $source = shift;
my $target = shift;
$self->exportViaRsync($source, $target);
$self->addTargetToNfsExports($target);
}
################################################################################
### implementation methods
################################################################################
sub exportViaRsync
{
my $self = shift;
my $source = shift;
my $target = shift;
my $excludeIncludeList
= join("\n", @{$self->{'include-list'}}, @{$self->{'exclude-list'}});
vlog 1, "using exclude-include-filter:\n$excludeIncludeList\n";
open(RSYNC, "| rsync -av --delete --exclude-from=- $source/ $target")
or die _tr("unable to start rsync for source '%s', giving up! (%s)",
$source, $!);
print RSYNC $excludeIncludeList;
if (!close(RSYNC)) {
die _tr("unable to export to target '%s', giving up! (%s)",
$target, $!);
}
}
sub addTargetToNfsExports
{
my $self = shift;
my $target = shift;
my $exports = slurpFile("/etc/exports");
print "$exports\n";
}
1;
|