diff options
author | Oliver Tappe | 2007-04-02 15:36:40 +0200 |
---|---|---|
committer | Oliver Tappe | 2007-04-02 15:36:40 +0200 |
commit | 086ccfc2d34e8401486b97eb05ace116a14fe353 (patch) | |
tree | 9afaa2e2345d05034aaaac2e64571f72b7b7588c /installer/OpenSLX/OSExport/ExportType | |
parent | * added support for removing a vendor-OS (from disk and config-DB) (diff) | |
download | core-086ccfc2d34e8401486b97eb05ace116a14fe353.tar.gz core-086ccfc2d34e8401486b97eb05ace116a14fe353.tar.xz core-086ccfc2d34e8401486b97eb05ace116a14fe353.zip |
* added support for removing an export (from disk and config-DB)
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@855 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer/OpenSLX/OSExport/ExportType')
-rw-r--r-- | installer/OpenSLX/OSExport/ExportType/Base.pm | 26 | ||||
-rw-r--r-- | installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm | 44 | ||||
-rw-r--r-- | installer/OpenSLX/OSExport/ExportType/NFS.pm | 34 |
3 files changed, 60 insertions, 44 deletions
diff --git a/installer/OpenSLX/OSExport/ExportType/Base.pm b/installer/OpenSLX/OSExport/ExportType/Base.pm index 864a6ffd..54d1f7e4 100644 --- a/installer/OpenSLX/OSExport/ExportType/Base.pm +++ b/installer/OpenSLX/OSExport/ExportType/Base.pm @@ -42,31 +42,13 @@ sub exportVendorOS { } -################################################################################ -### implementation methods -################################################################################ -sub copyViaRsync +sub purgeExport { - my $self = shift; - my $source = shift; - my $target = shift; - - if (system("mkdir -p $target")) { - die _tr("unable to create directory '%s', giving up! (%s)\n", - $target, $!); - } - my $includeExcludeList = $self->determineIncludeExcludeList(); - vlog 1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList); - 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 $includeExcludeList; - if (!close(RSYNC)) { - die _tr("unable to export to target '%s', giving up! (%s)", - $target, $!); - } } +################################################################################ +### implementation methods +################################################################################ sub determineIncludeExcludeList { my $self = shift; diff --git a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm index dc6bc2ed..4b1e078c 100644 --- a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm +++ b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm @@ -41,28 +41,28 @@ sub exportVendorOS my $source = shift; my $target = shift; - # TODO: once the include/exclude-patch by Vito has been applied - # to mksquashfs, the extra route via rsync isn't necessary anymore: - my $mksquashfsCanFilter = 1; - if ($mksquashfsCanFilter) { - my $includeExcludeList = $self->determineIncludeExcludeList(); - # in order to do the filtering as part of mksquashfs, we need to map - # our internal (rsync-)filter format to regexes: - $includeExcludeList - = mapRsyncFilter2Regex($source, $includeExcludeList); - vlog 1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList); - $self->createSquashFS($source, $target, $includeExcludeList); - } else { - # do filtering via an rsync copy: - vlog 0, _tr("taking detour via rsync..."); - my $tmpTarget = "${target}_###RSYNC_TMP###"; - $self->copyViaRsync($source, $tmpTarget); - $self->createSquashFS($tmpTarget, $target); -# system("rm -r $tmpTarget"); - } + my $includeExcludeList = $self->determineIncludeExcludeList(); + # in order to do the filtering as part of mksquashfs, we need to map + # our internal (rsync-)filter format to regexes: + $includeExcludeList + = mapRsyncFilter2Regex($source, $includeExcludeList); + vlog 1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList); + $self->createSquashFS($source, $target, $includeExcludeList); $self->showNbdParams($target); } +sub purgeExport +{ + my $self = shift; + my $target = shift; + + if (system("rm $target")) { + vlog 0, _tr("unable to remove export '%s'!", $target); + return 0; + } + 1; +} + ################################################################################ ### implementation methods ################################################################################ @@ -74,7 +74,7 @@ sub createSquashFS my $target = shift; my $includeExcludeList = shift; - system("rm -rf $target"); + system("rm -f $target"); # mksquasfs isn't significantly faster if fs already exists, but it # causes the filesystem to grow somewhat, so we remove it in order to # get the smallest FS-file possible. @@ -94,8 +94,8 @@ sub createSquashFS unlink($filterFile); # ... remove filter file if done if ($res) { - die _tr("unable to create squashfs for source '%s into target '%s', giving up! ($!)", - $source, $target); + die _tr("unable to create squashfs for source '%s' as target '%s', giving up! (%s)", + $source, $target, $!); } } diff --git a/installer/OpenSLX/OSExport/ExportType/NFS.pm b/installer/OpenSLX/OSExport/ExportType/NFS.pm index 8bb8ae48..b25736b8 100644 --- a/installer/OpenSLX/OSExport/ExportType/NFS.pm +++ b/installer/OpenSLX/OSExport/ExportType/NFS.pm @@ -46,9 +46,43 @@ sub exportVendorOS $self->addTargetToNfsExports($target); } +sub purgeExport +{ + my $self = shift; + my $target = shift; + + if (system("rm -r $target")) { + vlog 0, _tr("unable to remove export '%s'!", $target); + return 0; + } + 1; +} + ################################################################################ ### implementation methods ################################################################################ +sub copyViaRsync +{ + my $self = shift; + my $source = shift; + my $target = shift; + + if (system("mkdir -p $target")) { + die _tr("unable to create directory '%s', giving up! (%s)\n", + $target, $!); + } + my $includeExcludeList = $self->determineIncludeExcludeList(); + vlog 1, _tr("using include-exclude-filter:\n%s\n", $includeExcludeList); + 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 $includeExcludeList; + if (!close(RSYNC)) { + die _tr("unable to export to target '%s', giving up! (%s)", + $target, $!); + } +} + sub addTargetToNfsExports { my $self = shift; |