summaryrefslogtreecommitdiffstats
path: root/installer/OpenSLX/OSExport/BlockDevice/NBD.pm
diff options
context:
space:
mode:
authorOliver Tappe2007-06-20 20:04:19 +0200
committerOliver Tappe2007-06-20 20:04:19 +0200
commit898eca2232289d3f64431bc3763da4b65bb3ae61 (patch)
tree2a213ff0429b76037a6cc0f2fbf9f99ec025ed2a /installer/OpenSLX/OSExport/BlockDevice/NBD.pm
parent* added support for invoking a chrooted shell for any installed vendor-OS, (diff)
downloadcore-898eca2232289d3f64431bc3763da4b65bb3ae61.tar.gz
core-898eca2232289d3f64431bc3763da4b65bb3ae61.tar.xz
core-898eca2232289d3f64431bc3763da4b65bb3ae61.zip
* split export type into filesystem and (optional) blockdevice, closing
ticket#139 * code-reformatting with perltidy git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1176 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer/OpenSLX/OSExport/BlockDevice/NBD.pm')
-rw-r--r--installer/OpenSLX/OSExport/BlockDevice/NBD.pm91
1 files changed, 91 insertions, 0 deletions
diff --git a/installer/OpenSLX/OSExport/BlockDevice/NBD.pm b/installer/OpenSLX/OSExport/BlockDevice/NBD.pm
new file mode 100644
index 00000000..8afaa97f
--- /dev/null
+++ b/installer/OpenSLX/OSExport/BlockDevice/NBD.pm
@@ -0,0 +1,91 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# NBD.pm
+# - provides NBD+Squashfs-specific overrides of the
+# OpenSLX::OSExport::BlockDevice API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSExport::BlockDevice::NBD;
+
+use vars qw($VERSION);
+use base qw(OpenSLX::OSExport::BlockDevice::Base);
+$VERSION = 1.01; # API-version . implementation-version
+
+use strict;
+use Carp;
+use File::Basename;
+use OpenSLX::Basics;
+use OpenSLX::ConfigDB qw(:support);
+use OpenSLX::OSExport::BlockDevice::Base 1;
+use OpenSLX::Utils;
+
+################################################################################
+### interface methods
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {'name' => 'nbd',};
+ return bless $self, $class;
+}
+
+sub initialize
+{
+ my $self = shift;
+ my $engine = shift;
+ my $fs = shift;
+
+ $self->{'engine'} = $engine;
+ $self->{'fs'} = $fs;
+}
+
+sub getExportPort
+{
+ my $self = shift;
+ my $openslxDB = shift;
+
+ return $openslxDB->incrementGlobalCounter('next-nbd-server-port');
+}
+
+sub generateExportURI
+{
+ my $self = shift;
+ my $export = shift;
+
+ my $server =
+ length($export->{server_ip})
+ ? $export->{server_ip}
+ : generatePlaceholderFor('serverip');
+ $server .= ":$export->{port}" if length($export->{port});
+
+ return "nbd://$server";
+}
+
+sub requiredBlockDeviceModules
+{
+ my $self = shift;
+
+ return 'nbd';
+}
+
+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->{fs}->{'export-path'} -r"
+ );
+ print(('#' x 80) . "\n");
+}
+
+1;