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