[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#335230: Random Code so far to be cleaned



diff -urN yaird-0.0.11/perl/Evms.pm yaird-0.0.11-evms/perl/Evms.pm
--- yaird-0.0.11/perl/Evms.pm	1970-01-01 01:00:00.000000000 +0100
+++ yaird-0.0.11-evms/perl/Evms.pm	2005-10-24 18:31:24.000000000 +0200
@@ -0,0 +1,70 @@
+#!perl -w
+#
+# Evms -- encapsulate evms_gather output
+#   Copyright (C) 2005  Erik van Konijnenburg, Marco Amadori
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of 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.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+#
+
+use strict;
+use warnings;
+use Base;
+use Conf;
+use base 'Obj';
+package Evms;
+
+sub fill {
+	my $self = shift;
+	$self->SUPER::fill();
+	$self->takeArgs ('path', 'devno', 'disks', 'plugins', 'version');
+}
+
+sub path	{ return $_[0]->{path}; }
+sub devno	{ return $_[0]->{devno}; } # 4 what?
+sub disks	{ return $_[0]->{disks}; }
+sub plugins	{ return $_[0]->{plugins}; } # not implemented
+sub version	{ return $_[0]->{version}; }
+
+sub string {
+	my $self = shift;
+	my $path = $self->path;
+	my $devno = $self->devno;
+	my $disks = join (',', @{$self->disks});
+	my $plugins = join (',', @{$self->plugins});
+	return "$path($devno) = $plugins on $disks";
+}
+
+
+sub findDisksByName ($) {
+# should provide a list from evms_query disks <name>
+# like the output of the shell command
+# evms_query disks /dev/evms/lvm2/safe/usr64 | xargs -i echo /dev/\{\}
+# /dev/sda
+# /dev/sdb
+# /dev/sdc
+	my ($name) = @_;
+	
+	return $evms->disks;
+	
+	
+sub findVersion () {
+# equivalent of evms_query info | head -1 | cut -d ' ' -f 3
+# e.g. from the output "EVMS Version: 2.5.3 \
+#  EVMS Engine API Version: 10.1.0" gives "2.5.3"
+
+	return $evms->version;
+}
+
+1;
diff -urN yaird-0.0.11/perl/Plan.pm yaird-0.0.11-evms/perl/Plan.pm
--- yaird-0.0.11/perl/Plan.pm	2005-08-07 22:57:40.000000000 +0200
+++ yaird-0.0.11-evms/perl/Plan.pm	2005-10-24 18:28:12.375146768 +0200
@@ -1,7 +1,7 @@
 #!perl -w
 #
 # Plan -- high-level stuff
-#   Copyright (C) 2005  Erik van Konijnenburg
+#   Copyright (C) 2005  Erik van Konijnenburg, Marco Amadori
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 use FsTab;
 use ActiveBlockDevTab;
 use LvmTab;
+use Evms;
 use Hardware;
 use ModProbe;
 use RaidTab;
@@ -83,6 +84,7 @@
 	}
 
 	my $ok = 0;
+	$ok || ($ok = tryEvms ($actions,$device,[$device,@{$working}]));
 	$ok || ($ok = tryParent ($actions,$device,[$device,@{$working}]));
 	$ok || ($ok = tryDmCrypt ($actions,$device,[$device,@{$working}]));
 	$ok || ($ok = tryLvm ($actions,$device,[$device,@{$working}]));
@@ -93,6 +95,35 @@
 	}
 	Base::debug ("device: completed $name");
 }
+#
+# tryEvms -- 
+#
+
+sub tryEvms ($$$) {
+	my ($actions, $device, $working) = @_;
+
+	my $name = $device->name; # If name is like /dev/evms/root, if is like dm-3 
I'm lost
+	if ($name !~ /^dm-\d+$/) {
+		return 0;
+	}
+
+	for my $evmsDisk (@{Evms::findDisksByName($name)}) 
+	{
+		my $pdev = ActiveBlockDevTab::findByPath ($evmsDisk);
+		my $rc = tryHardware ($actions, $pdev, $working);
+		if ($rc !~ 1) {
+			# Base::fatal ("Can't find EVMS info for $name");
+			return 0;
+		}
+		
+	}
+	my $version = Evms::findVersion ()
+	ModProbe::addModules ($actions, [ "dm-mod" ]);
+	$actions->add ("evms_activate", $version);
+	
+	return 1;
+}
+
 
 #
 # tryParent -- If it's a partition, do the whole
diff -urN yaird-0.0.11/templates/Debian.cfg 
yaird-0.0.11-evms/templates/Debian.cfg
--- yaird-0.0.11/templates/Debian.cfg	2005-08-07 22:57:40.000000000 +0200
+++ yaird-0.0.11-evms/templates/Debian.cfg	2005-10-24 17:57:31.434012360 +0200
@@ -250,6 +250,23 @@
 			!/sbin/vgchange -a y '<TMPL_VAR NAME=target>'
 		END SCRIPT
 	END TEMPLATE
+	
+	TEMPLATE evms_activate
+	BEGIN
+		DIRECTORY "/lib/evms/<TMPL_VAR NAME=version>" # Instead of this two lines
+		FILE "/lib/evms/<TMPL_VAR NAME=version>/*.so" # should be used 
addTreeLibrary or similar
+
+		FILE "/sbin/evms_activate"
+		FILE "/etc/evms.conf"
+		SCRIPT "/init"
+		BEGIN
+			!if [ ! -c /dev/evms ]
+			!then
+			!	/bin/mkdir /dev/evms
+			!fi
+			!/sbin/evms_activate 
+		END SCRIPT
+	END TEMPLATE
 
 	#
 	# NOTE: mdadm can operate without knowledge


ESC:wq



Reply to: