# -*-perl-*-

# $Id$

# This package provides the afs atom objects.  It inherits almost everything
# from the generic Atom object.

# $Log$
# Revision 1.5  2010/08/05 16:59:27  koczan
# altered atom weight
#
# Revision 1.4  2008/01/31 17:34:00  thomas
# Don't need sushiremote_wrapper, just sushiremote
#
# Revision 1.3  2004/03/11 21:58:43  thomas
# Clean up ssh calls to use /usr/bin/ssh
#
# Revision 1.2  2004/03/04 20:40:25  thomas
# [CSL #180910]
#
# Revision 1.1  2002/07/08 15:56:33  thomas
# 0.2.3 release
#
# Revision 1.1.1.1  2002/05/21 14:13:31  thomas
# sushi - backup to disk
#

package Sushi::RemoteHostAtom;

use strict;
use Time::localtime;

use base qw(Sushi::HostAtom);

###############################################################################
# Get the execute Host for the atom.  This comes from the atom name.

sub executeHost {
  my $self = shift;

  foreach my $weight (@{$self->getWeights}) {
    if ($weight->{resource_type} eq "Worker") {
      return $weight->{resource_name};
    }
  }
  $self->error ("executeHost failed for " . $self->commonName . "!\n");
  return undef;
}

###############################################################################
# Return the command used to execute the child atom.

sub getChildCmd {
  my $self = shift;
  my $timestamp = shift;

  my @argv = ('/usr/bin/ssh', '-2', '-x', '-n');

  foreach my $weight (@{$self->getWeights}) {
    if ($weight->{resource_type} eq "Worker") {
      push @argv, $weight->{resource_name};
    }
  }

  $::debug>3 and push @argv, "time";

  push @argv, "/s/sushi-0.3.22/bin/sushiremote", $self->{id}, $timestamp;

  return @argv;
}

###############################################################################

sub setConstraintsDumpType {
  my $self = shift;
  my $hints = shift;

  $self->setWeight ( {
		      resource_type  => "Worker",
		      resource_alias => '@Worker@',
		      resource_name  => '',
		      weight         => 10
		     } ) or return 0;
  return 1;
}

###############################################################################
# For remote host atoms, we don't need a host acl

sub needHostAcl { undef; }

###############################################################################
# For remote host atoms, we don't need to create pts users for atoms.

sub createPts { undef; }

###############################################################################

1;
