From d561c9b1d1440185a5000c3d4df4395ba6de9a22 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 29 May 2007 20:06:16 +0000 Subject: * changed handling of exports to drop support for having more than one export for a given vendor-OS with the same export-type * exports are now named according to the pattern - (instead of - where X was a letter) * change slxos-export to show the export-config-info after updating an export, too (not only after creating a new export). git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1108 95ad53e4-c205-0410-b2fa-d234c58c8868 --- installer/OpenSLX/OSExport/Engine.pm | 59 ++++++++++------------ installer/OpenSLX/OSExport/ExportType/Base.pm | 4 ++ .../OpenSLX/OSExport/ExportType/NBD_Squash.pm | 23 ++++----- installer/OpenSLX/OSExport/ExportType/NFS.pm | 29 +++++------ installer/slxos-export | 36 ++----------- 5 files changed, 61 insertions(+), 90 deletions(-) diff --git a/installer/OpenSLX/OSExport/Engine.pm b/installer/OpenSLX/OSExport/Engine.pm index 4ffae1a8..6264471a 100644 --- a/installer/OpenSLX/OSExport/Engine.pm +++ b/installer/OpenSLX/OSExport/Engine.pm @@ -108,9 +108,7 @@ sub initializeForNew die _tr("vendor-OS '%s' not found in DB, giving up!", $vendorOSName); } - my $exportCounter - = $openslxDB->incrementExportCounterForVendorOS($vendorOS->{id}); - my $exportName = sprintf "$vendorOSName-%c", 64+$exportCounter; + my $exportName = "$vendorOSName-$exportType"; $openslxDB->disconnect(); @@ -135,22 +133,6 @@ sub exportVendorOS $self->addExportToConfigDB(); } -sub updateExportedVendorOS -{ - my $self = shift; - my $exportName = shift; - - if (!$self->{'exporter'}->checkRequirements($self->{'vendor-os-path'})) { - die _tr("clients wouldn't be able to access the exported root-fs!\nplease install the missing module(s) or use another export-type."); - } - - $self->{'exporter'}->exportVendorOS( - $self->{'vendor-os-path'}, - $self->{'export-path'} - ); - vlog 0, _tr("export '%s' successfully updated!", $self->{'export-path'}); -} - sub purgeExport { my $self = shift; @@ -236,7 +218,7 @@ sub _initialize $self->{'vendor-os-path'} = "$openslxConfig{'stage1-path'}/$vendorOSName"; $self->{'export-path'} - = "$openslxConfig{'export-path'}/$exportType/$exportName"; + = "$openslxConfig{'export-path'}/$exportType/$vendorOSName"; vlog 1, _tr("vendor-OS from '%s' will be exported to '%s'", $self->{'vendor-os-path'}, $self->{'export-path'}); } @@ -248,17 +230,31 @@ sub addExportToConfigDB my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); $openslxDB->connect(); - my $export = { - 'vendor_os_id' => $self->{'vendor-os-id'}, - 'name' => $self->{'export-name'}, - 'type' => $self->{'export-type'}, - }; - - my $id = $self->{exporter}->addExportToConfigDB($export, $openslxDB); - vlog 0, _tr("Export '%s' has been added to DB (ID=%s)...\n", - $self->{'export-name'}, $id); - # now create a default system for that export, using the standard kernel: - system("slxconfig add-system $self->{'export-name'}"); + my $export + = $openslxDB->fetchExportByFilter({ + 'name' => $self->{'export-name'}, + 'vendor_os_id' => $self->{'vendor-os-id'}, + }); + if (defined $export) { + vlog 0, _tr("No need to change export '%s' in OpenSLX-database.\n", + $self->{'export-name'}); + $self->{exporter}->showExportConfigInfo($export); + } else { + $export = { + 'vendor_os_id' => $self->{'vendor-os-id'}, + 'name' => $self->{'export-name'}, + 'type' => $self->{'export-type'}, + }; + + my $id = $self->{exporter}->addExportToConfigDB($export, $openslxDB); + vlog 0, _tr("Export '%s' has been added to DB (ID=%s)...\n", + $self->{'export-name'}, $id); + + $self->{exporter}->showExportConfigInfo($export) if $id; + + # now create a default system for that export, using the standard kernel: + system("slxconfig add-system $self->{'export-name'}"); + } $openslxDB->disconnect(); } @@ -275,7 +271,6 @@ sub removeExportFromConfigDB my $export = $openslxDB->fetchExportByFilter({ 'name' => $exportName, - 'type' => $self->{'export-type'}, }); if (!defined $export) { vlog 0, _tr("Export '%s' doesn't exist in OpenSLX-database.\n", diff --git a/installer/OpenSLX/OSExport/ExportType/Base.pm b/installer/OpenSLX/OSExport/ExportType/Base.pm index e0f5c5be..7e0aa464 100644 --- a/installer/OpenSLX/OSExport/ExportType/Base.pm +++ b/installer/OpenSLX/OSExport/ExportType/Base.pm @@ -68,6 +68,10 @@ sub requiredFSMods { } +sub showExportConfigInfo +{ +} + ################################################################################ ### implementation methods ################################################################################ diff --git a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm index f721d6d2..bb26a619 100644 --- a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm +++ b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm @@ -113,7 +113,6 @@ sub addExportToConfigDB = $openslxDB->incrementGlobalCounter('next-nbd-server-port'); my $res = $openslxDB->addExport($export); - $self->showNbdParams($export) if $res; return $res; } @@ -138,6 +137,17 @@ sub requiredFSMods return 'nbd squashfs'; } +sub showExportConfigInfo +{ + my $self = shift; + my $export = shift; + + print (('#' x 80)."\n"); + print _tr("Please make sure you start a corresponding nbd-server:\n\t%s\n", + "nbd-server $export->{port} $self->{engine}->{'export-path'} -r"); + print (('#' x 80)."\n"); +} + ################################################################################ ### implementation methods ################################################################################ @@ -182,17 +192,6 @@ sub createSquashFS } } -sub showNbdParams -{ - my $self = shift; - my $export = shift; - - print (('#' x 80)."\n"); - print _tr("Please make sure you start a corresponding nbd-server:\n\t%s\n", - "nbd-server $export->{port} $self->{engine}->{'export-path'} -r"); - print (('#' x 80)."\n"); -} - sub mapRsyncFilter2Regex { my $sourcePath = shift; diff --git a/installer/OpenSLX/OSExport/ExportType/NFS.pm b/installer/OpenSLX/OSExport/ExportType/NFS.pm index e3cd9cce..f63a2d23 100644 --- a/installer/OpenSLX/OSExport/ExportType/NFS.pm +++ b/installer/OpenSLX/OSExport/ExportType/NFS.pm @@ -44,7 +44,6 @@ sub exportVendorOS my $target = shift; $self->copyViaRsync($source, $target); - $self->addTargetToNfsExports($target); } sub purgeExport @@ -80,6 +79,20 @@ sub requiredFSMods return 'nfs'; } +sub showExportConfigInfo +{ + my $self = shift; + my $export = shift; + + print (('#' x 80)."\n"); + print _tr("Please make sure the following line is contained in /etc/exports\nin order to activate the NFS-export of this vendor-OS:\n\t%s\n", + "$self->{engine}->{'export-path'}\t*(ro,no_root_squash,async,no_subtree_check)"); + print (('#' x 80)."\n"); + +# TODO : add something a bit more clever here... +# my $exports = slurpFile("/etc/exports"); +} + ################################################################################ ### implementation methods ################################################################################ @@ -105,18 +118,4 @@ sub copyViaRsync } } -sub addTargetToNfsExports -{ - my $self = shift; - my $target = shift; - - print (('#' x 80)."\n"); - print _tr("Please make sure the following line is contained in /etc/exports\nin order to activate the NFS-export of this vendor-OS:\n\t%s\n", - "$self->{engine}->{'export-path'}\t*(ro,no_root_squash,async,no_subtree_check)"); - print (('#' x 80)."\n"); - -# TODO : add something a bit more clever here... -# my $exports = slurpFile("/etc/exports"); -} - 1; diff --git a/installer/slxos-export b/installer/slxos-export index 6b44d5ef..4ba63ec2 100755 --- a/installer/slxos-export +++ b/installer/slxos-export @@ -84,7 +84,7 @@ if ($action =~ m[^list-ex]i) { } elsif ($action =~ m[^list-ty]i) { print _tr("List of supported export types:\n\t"); print join("\n\t", sort keys %supportedExportTypes)."\n"; -} elsif ($action =~ m[^(add|export)]i) { +} elsif ($action =~ m[^export]i) { if (scalar(@ARGV) != 2) { print STDERR _tr("You need to specify exactly one vendor-os-name and one export-type!\n"); pod2usage(2); @@ -105,29 +105,9 @@ if ($action =~ m[^list-ex]i) { $engine->{'vendor-os-path'}); } $engine->exportVendorOS(); -} elsif ($action =~ m[^(update)]i) { - if (scalar(@ARGV) != 1) { - print STDERR _tr("You need to specify exactly one export-name!\n"); - pod2usage(2); - } - my $exportName = shift @ARGV; - - # we chdir into the script's folder such that all relative paths have - # a known starting point: - chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - # create OSExport-engine for given export type and start it: - my $engine = OpenSLX::OSExport::Engine->new; - $engine->initializeFromExisting($exportName); - if (!-e $engine->{'vendor-os-path'}) { - die _tr("vendor-OS '%s' doesn't exist, giving up!\n", - $engine->{'vendor-os-path'}); - } - $engine->updateExportedVendorOS(); } elsif ($action =~ m[^remove]i) { if (scalar(@ARGV) != 1) { - print STDERR _tr("You need to specify exactly one export-name and one export-type!\n"); + print STDERR _tr("You need to specify exactly one export-name!\n"); pod2usage(2); } my $exportName = shift @ARGV; @@ -143,11 +123,10 @@ if ($action =~ m[^list-ex]i) { $engine->purgeExport(); } else { print STDERR _tr("You need to specify exactly one action: - add + export list-exported list-installed list-types - update remove Try '%s --help' for more info.\n", $0); } @@ -173,12 +152,12 @@ slxos-export [options] =over 8 -=item B<< add >> +=item B<< export >> exports the vendor-OS with the given name using the given export type and adds it to the config-DB, too. The export will be named as the vendor-OS, but with an additional '-' appended to it (where will be replaced -by the letter A,B,C ...). +by the chosen export-type). =item B<< list-exported >> @@ -192,11 +171,6 @@ list all installed vendor-OSes list all supported export types -=item B<< update >> - -updates the export with the given name, i.e. the contents of the vendor-OS -is synced to the export - =item B<< remove >> removes the export with the given name from disk and config-DB -- cgit v1.2.3-55-g7522