1 |
--- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape.rotateupdate 2008-11-25 09:46:02.000000000 -0700 |
2 |
+++ smeserver-arkeia-1.0/root/etc/e-smith/events/actions/rotate-tape 2008-11-25 09:45:32.000000000 -0700 |
3 |
@@ -16,10 +16,19 @@ |
4 |
my $confdb = esmith::ConfigDB->open; |
5 |
my $arkeia = $confdb->get('arkeia') or die "No arkeia db entry found\n"; |
6 |
my $rotate = $arkeia->prop('Rotate') || 'no'; |
7 |
+my $drivenum = $arkeia->prop('DriveNum') || 0; |
8 |
+my $offset = $arkeia->prop('Offset') || 0; |
9 |
my $changer = $arkeia->prop('Changer') || '/dev/changer'; |
10 |
+my $host = $arkeia->prop('Host') || 'localhost'; |
11 |
|
12 |
-exit 0 unless $rotate eq 'yes'; |
13 |
-exit 0 unless -c $changer; |
14 |
+my $mtxcmd = "mtx -f $changer"; |
15 |
+if ($rotate eq 'remote') { |
16 |
+ $mtxcmd = "ssh $host $mtxcmd"; |
17 |
+} elsif ($rotate ne 'yes') { |
18 |
+ exit 0 unless -c $changer; |
19 |
+} else { |
20 |
+ exit 0 |
21 |
+} |
22 |
|
23 |
my $daily = $arkeia->prop("Daily") || 0; |
24 |
my $weekly = $arkeia->prop("Weekly") || 0; |
25 |
@@ -52,6 +61,12 @@ |
26 |
} |
27 |
} |
28 |
exit 0 unless $slot; |
29 |
+$slot += $offset; |
30 |
|
31 |
-system("/usr/sbin/mtx -f $changer unload &> /dev/null"); |
32 |
-system("/usr/sbin/mtx -f $changer load $slot") && die("A problem occurred execing mtx\n"); |
33 |
+my @status = qx($mtxcmd status); |
34 |
+my $loaded = (grep { /Data Transfer Element $drivenum:Full/ } @status)[0]; |
35 |
+if ( $loaded && $loaded =~ m{ Element (\d+):Full .* Element (\d+) } ) { |
36 |
+ exit 0 if $2 == $slot; |
37 |
+ system("$mtxcmd unload $2 $1"); |
38 |
+} |
39 |
+system("$mtxcmd load $slot $drivenum") && die("A problem occurred execing mtx\n"); |