[Swift-commit] r3491 - in usertools/swift/swiftconfig: bin etc/sites etc/sites/localhost etc/sites/pads-local-pbs etc/sites/pads-local-pbs-coasters etc/sites/pads-remote-pbs-coasters-ssh etc/sites/pads-remote-ssh etc/sites/teraport-local-pbs etc/sites/teraport-local-pbs-coasters etc/sites/teraport-remote-ssh

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Jul 30 04:43:43 CDT 2010


Author: davidk
Date: 2010-07-30 04:43:43 -0500 (Fri, 30 Jul 2010)
New Revision: 3491

Added:
   usertools/swift/swiftconfig/etc/sites/localhost/
   usertools/swift/swiftconfig/etc/sites/localhost/sites.xml
   usertools/swift/swiftconfig/etc/sites/localhost/tc.data
Removed:
   usertools/swift/swiftconfig/etc/sites/multisite-pbs-coasters/
   usertools/swift/swiftconfig/etc/sites/multisite-ssh/
Modified:
   usertools/swift/swiftconfig/bin/swiftconfig
   usertools/swift/swiftconfig/bin/swiftrun
   usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/sites.xml
   usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/tc.data
   usertools/swift/swiftconfig/etc/sites/pads-local-pbs/tc.data
   usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/sites.xml
   usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/tc.data
   usertools/swift/swiftconfig/etc/sites/pads-remote-ssh/tc.data
   usertools/swift/swiftconfig/etc/sites/teraport-local-pbs-coasters/tc.data
   usertools/swift/swiftconfig/etc/sites/teraport-local-pbs/tc.data
   usertools/swift/swiftconfig/etc/sites/teraport-remote-ssh/tc.data
Log:


Modified: usertools/swift/swiftconfig/bin/swiftconfig
===================================================================
--- usertools/swift/swiftconfig/bin/swiftconfig	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/bin/swiftconfig	2010-07-30 09:43:43 UTC (rev 3491)
@@ -5,60 +5,64 @@
 use File::Copy;
 use File::Path;
 
-my $swifthome = '';
+my $swift_home = q{};
 if ( $ENV{'SWIFT_HOME'} && -e "$ENV{'SWIFT_HOME'}/bin/swift" ) {
-    $swifthome = $ENV{'SWIFT_HOME'};
+    $swift_home = $ENV{'SWIFT_HOME'};
 }
 
-my @path = split( '/', abs_path($0) );
-my @path = splice( @path, 0, $#path - 1 );
-my $parent_directory = join( '/', @path );
+my @execution_path = split( '/', abs_path($0) );
+my @execution_path = splice( @execution_path, 0, $#execution_path - 1 );
+my $parent_directory = join( '/', @execution_path );
 
-if ( !$swifthome ) {
+if ( !$swift_home ) {
     if ( -e "$parent_directory/bin/swift" ) {
-        $swifthome = $parent_directory;
+        $swift_home = $parent_directory;
     }
 
     else {
-        @path = split( '/', which("swift") );
-        @path = splice( @path, 0, $#path - 1 );
-        my $tmp = join( '/', @path );
+        @execution_path = split( '/', which("swift") );
+        @execution_path = splice( @execution_path, 0, $#execution_path - 1 );
+        my $tmp = join( '/', @execution_path );
         if ( -e "$tmp/bin/swift" ) {
-            $swifthome = $tmp;
+            $swift_home = $tmp;
         }
     }
 }
 
 use FindBin qw($Bin);
-use lib "$FindBin::Bin/../lib/perl";    # Use libraries in $swifthome/lib/perl
+use lib "$FindBin::Bin/../lib/perl";   # Use libraries in $swift_home/lib/perl
 use Getopt::Long;
 use File::Which qw(which where);
 use XML::Simple;
 use Data::Dumper;
 
 # Variables used for translation catalog
-my $host     = 'localhost';             # Host name
-my $name     = '';                      # Translation name
-my $path     = "/usr/bin/$name";        # Full path of executable location
-my $status   = 'INSTALLED';             # Installation status (not used)
-my $platform = 'INTEL32::LINUX';        # Platform (not used)
-my $profile  = 'null';                  # Profile entries
+my $tc_host     = 'localhost';         # Host name
+my $tc_name     = q{};                 # Translation name
+my $tc_path     = "/usr/bin/$name";    # Full path of executable location
+my $tc_status   = 'INSTALLED';         # Installation status (not used)
+my $tc_platform = 'INTEL32::LINUX';    # Platform (not used)
+my $tc_profile  = 'null';              # Profile entries
 
 # Variables used for sites.xml
-my $templates = 0;                      # List all templates
-my $remove    = '';                     # Remove entry from sites.xml
-my $modify    = '';                     # Modify mode
-my @validproviders = ( "gt4", "local", "pbs", "condor", "ssh", "coaster" );
-my $keyfile  = "$ENV{'HOME'}/.ssh/id_rsa";
+my $option_templates = q{};            # List all templates
+my $option_remove    = q{};            # Remove entry from sites.xml
+my $option_modify    = q{};            # Modify mode
+my $option_add       = q{};            # Add entry
+my $option_sites     = q{};            # List all usable sites
+my @execution_providers =
+    ( "gt4", "local", "pbs", "condor", "ssh", "coaster", );
+my $key_file = "$ENV{'HOME'}/.ssh/id_rsa";
 
 # Assign variables from command line options
 GetOptions(
-    'add=s'       => \$add,
-    'remove=s'    => \$remove,
-    'templates'   => \$templates,
-    'modify=s'    => \$modify,
-    'swifthome=s' => \$swifthome,
-    'sites'     => \$sites
+    'add=s'        => \$option_add,
+    'remove=s'     => \$option_remove,
+    'templates'    => \$option_templates,
+    'modify=s'     => \$option_modify,
+    'swift_home=s' => \$swift_home,
+    'sites'        => \$option_sites,
+    'describe=s'   => \$option_describe,
 );
 
 # Create a new directory if it does not exist
@@ -66,281 +70,386 @@
     $directory = $_[0];
     if ( !-d "$directory" ) {
         mkdir "$directory", 0700
-          or die "Unable to create directory $directory\n";
+            or die "Unable to create directory $directory\n";
     }
 }
 
 # Process keyboard input
-sub getEntry {
-    my ($description, $value, @valid) = @_;
+sub get_entry {
+    my ( $entry_description, $entry_value, @allowable_values, ) = @_;
 
-    print "$description [$value]: ";
-    my $newvalue = "";
-    chomp($newvalue = <STDIN>);
-    if ($newvalue) { $value = $newvalue; }
-    my $isvalid = 0;
+    print "$entry_description [$entry_value]: ";
+    my $new_value = <STDIN>;
+    chomp($new_value);
+    if ($new_value) {
+        $entry_value = $new_value;
+    }
 
-    if(@valid) {
-        foreach(@valid) {
-            if($_ eq $value){ $isvalid = 1; }
+    # Check if value entered is valid (if valid values were passed)
+    my $is_valid = 0;
+    if (@allowable_values) {
+        foreach my $allowable (@allowable_values) {
+            if ( $allowable eq $entry_value ) {
+                $is_valid = 1;
+            }
         }
-        if(!$isvalid) {
-            my $msg = "";
-	    foreach(@valid) { $msg .=  $_ . " "; }
-	    print "Invalid value selected. Please select from: $msg\n";
-            $value = getEntry($description, $value, @valid);
+        if ( !$is_valid ) {
+            my $error_message = q{};
+            foreach my $allowable (@allowable_values) {
+                $error_message = $error_message . $allowable . ' ';
+            }
+            print 'Invalid value selected. Please select from: '
+                . "$error_message\n";
+            $entry_value = get_entry( $entry_description, $entry_value,
+                @allowable_entry_values, );
         }
     }
 
-    return $value;
+    return $entry_value;
 }
 
 # Prepare data
 my $xml = new XML::Simple();
 
 # Create all required directories
-my $dotswift = "$ENV{'HOME'}/.swift";
+my $dotswift_directory = "$ENV{'HOME'}/.swift";
 create_directory("$ENV{'HOME'}/.ssh");
-create_directory("$dotswift");
-create_directory("$dotswift/sites");
+create_directory("$dotswift_directory");
+create_directory("$dotswift_directory/sites");
 
 # Determine the template directory
-my @path = split( '/', abs_path($0) );
-my @path = splice( @path, 0, $#path - 1 );
-my $template_directory = join( '/', @path ) . "/etc/sites";
+my @execution_path = split( '/', abs_path($0) );
+ at execution_path = splice( @execution_path, 0, $#execution_path - 1 );
+my $template_directory = join( '/', @execution_path ) . '/etc/sites';
 
 # Add new entry to auths.default
-sub add_ssh_auth
-{
-    my ($entry, $site) = @_;
-
+sub add_ssh {
+    my ( $ssh_site, $ssh_url) = @_;
+    
     # Open authfile
-    my $authfile = "$dotswift/sites/$entry/auth.defaults";
-    create_directory("$dotswift/sites/$entry");
-    if ( -e "$authfile" ) { open( AUTHFILE, "$authfile" ) || die "Unable to open auth file $authfile for reading!\n"; }
-    else { open( AUTHFILE, ">$authfile" ) || die "Unable to open $authfile for writing!\n"; }
-    @authdata = <AUTHFILE>;
-    close(AUTHFILE);
+    my $auth_file = "$dotswift_directory/sites/$ssh_site/auth.defaults";
+    create_directory("$dotswift_directory/sites/$ssh_site");
+    if ( -e "$auth_file" ) {
+        open( AUTH_FILE, "$auth_file" )
+            || die "Unable to open auth file $auth_file for reading!\n";
+    }
+    else {
+        open( AUTH_FILE, ">$auth_file" )
+            || die "Unable to open $auth_file for writing!\n";
+    }
+    my @auth_data = <AUTH_FILE>;
+    close(AUTH_FILE);
 
     # Create RSA keypair if needed
-    if ( !-e "$keyfile" ) {
-        system("ssh-keygen -t rsa -f $keyfile");
-    }
+    #my $keyfile = "$ENV{'HOME'}/.ssh/auth.defaults";
+    #if ( !-e "$keyfile" ) {
+    #    system("ssh-keygen -t rsa -f $keyfile");
+    #}
 
     # Get existing username and passphrase values
-    my $username;
-    my $passphrase;
-    foreach (@authdata) {
-        if (/username/i) { (my $blah, $username) = split('=', $_); chomp($username); }
-        if (/passphrase/i) { (my $blah, $passphrase) = split('=', $_); chomp($passphrase); } 
+    my $ssh_username;
+    my $ssh_passphrase;
+    foreach (@auth_data) {
+        if (/username/i) {
+            ( my $not_used, $ssh_username, ) = split( '=', $_ );
+            chomp($ssh_username);
+        }
+        if (/passphrase/i) {
+            ( my $not_used, $ssh_passphrase, ) = split( '=', $_ );
+            chomp($ssh_passphrase);
+        }
     }
-    if(!$username){ $username = getlogin(); }
+    if ( !$ssh_username ) {
+        $ssh_username = getlogin();
+    }
+    $ssh_username   = get_entry( 'Username',   $ssh_username );
+    $ssh_passphrase = get_entry( 'Passphrase', $ssh_passphrase );
 
-    $username = getEntry("Username", $username);
-    $passphrase = getEntry("Passphrase", $passphrase);
-
     # Remove old auth.defaults if it already exists
-    if(-e "$authfile") { 
-        unlink($authfile) || die "Unable to remove $authfile\n"; 
-        @authdata = ();
+    if ( -e "$auth_file" ) {
+        unlink($auth_file) || die "Unable to remove $auth_file\n";
+        @auth_data = ();
     }
 
-    # Add data to new auth.defaults
-    push( @authdata, "$site.type=key\n" );
-    push( @authdata, "$site.username=$username\n" );
-    push( @authdata, "$site.key=$keyfile\n" );
-    push( @authdata, "$site.passphrase=$passphrase\n" );
-    write_file( $authfile, @authdata );
+    # Key based authentication
+    #push( @authdata, "$site.type=key\n" );
+    #push( @authdata, "$site.username=$username\n" );
+    #push( @authdata, "$site.key=$keyfile\n" );
+    #push( @authdata, "$site.passphrase=$passphrase\n" );
+
+    # Password based authentication
+    push( @auth_data, "$ssh_url.type=password\n" );
+    push( @auth_data, "$ssh_url.username=$ssh_username\n" );
+    push( @auth_data, "$ssh_url.password=$ssh_passphrase\n" );
+    write_file( $auth_file, @auth_data );
 }
 
 # Update TC with correct hostname
 sub update_tc_hostname {
-    my ($filename, $host) = @_;
+    my ( $tc_filename, $tc_host ) = @_;
+
     # Store TC data
-    open( TCFILESTREAM, "$filename" ) or die("Unable to open tc file $tcfile!");
-    @tcdata = <TCFILESTREAM>;
-    close(TCFILESTREAM);
+    open( TC_FILESTREAM, "$tc_filename" )
+        or die("Unable to open tc file $tc_filename!");
+    @tc_data = <TC_FILESTREAM>;
+    close(TC_FILESTREAM);
 
-    foreach $line (@tcdata) {
+    foreach $line (@tc_data) {
+
         # Ignore comments
-        if ( substr( $line, 0, 1 ) eq '#' ) {
+        my $first_character = substr( $line, 0, 1 );
+        if ( $first_character eq '#' ) {
             next;
         }
 
-	# Replace old entry with new entry
-        my ( $tmphost, $tmpname, $tmppath, $tmpstatus, $tmpplatform, $tmpprofile ) = split( /\s+/, $line );
-        $tmphost = $host;
-        $line    = "$tmphost\t$tmpname\t$tmppath\t$tmpstatus\t$tmpplatform\t$tmpprofile\n";
-   }
+        # Replace old entry with new entry
+        my ($line_tc_host,   $line_tc_name,     $line_tc_path,
+            $line_tc_status, $line_tc_platform, $line_tc_profile,
+        ) = split( /\s+/, $line );
+        $line =
+              "$tc_host\t"
+            . "$line_tc_name\t"
+            . "$line_tc_path\t"
+            . "$line_tc_status\t"
+            . "$line_tc_platform\t"
+            . "$line_tc_profile\n";
+    }
 
-   write_file( $filename, @tcdata);
+    write_file( $tc_filename, @tc_data );
 }
 
 # Update XML hash with values from command line
-sub update_xml_entry {
+sub update_xml {
 
-    my ($filename) = @_;
-    if ( !-e $filename ) { return 0; }
-    my $entryname = "";
-    my $tcfile = "";
+    # Set up data
+    my ($xml_filename) = @_;
+    if ( !-e $xml_filename ) {
+        die "Unable to update xml file $xml_filename\n";
+    }
 
-    my $xml_data = $xml->XMLin(
-        $filename,
+    my $xml_ref = $xml->XMLin(
+        $xml_filename,
         ForceArray => [qw(workdirectory profile)],
-        KeyAttr    => []
+        KeyAttr    => [],
     );
 
-    # Renaming
-    if($modify)
-    {
-	$entryname = getEntry("Site Entry Name", $modify);
-	$tcfile = "$dotswift/sites/$modify/tc.data";
-        if($entryname ne $modify) {
-            if(!-d "$dotswift/sites/$entryname" && -d "$dotswift/sites/$modify") {
-                move("$dotswift/sites/$modify", "$dotswift/sites/$entryname") || die "Unable to rename $dotswift/sites/$modify to $dotsite/sites/$entryname";
-            }
-    	    $xml_data = $xml->XMLin("$dotswift/sites/$entryname/sites.xml", ForceArray => [qw(workdirectory profile)], KeyAttr => []);
-            $tcfile = "$dotswift/sites/$entryname/tc.data";
+    # Handle
+    $xml_ref->{handle} = get_entry( 'Site Entry Name', $xml_ref->{handle} );
+
+    # Grid FTP
+    if ( $xml_ref->{gridftp} ) {
+        $xml_ref->{gridftp}{url} =
+            get_entry( 'GridFTP URL', $xml_ref->{gridftp}{url} );
+    }
+
+    # Work directory
+    if ( $xml_ref->{workdirectory} ) {
+        $xml_ref->{workdirectory}[0] =~ s/\$HOME/$ENV{'HOME'}/;
+        $xml_ref->{workdirectory} =
+            [ get_entry( 'Work Directory', $xml_ref->{workdirectory}[0] ) ];
+    }
+
+    # Job manager
+    if ( $xml_ref->{jobmanager} ) {
+        if ( $xml_ref->{jobmanager}{universe} ) {
+            $xml_ref->{jobmanager}{universe} =
+                get_entry( 'Job Universe', $xml_ref->{jobmanager}{universe} );
         }
+        if ( $xml_ref->{jobmanager}{url} ) {
+            $xml_ref->{jobmanager}{url} =
+                get_entry( 'Job Manager URL', $xml_ref->{jobmanager}{url} );
+        }
+        if ( $xml_ref->{jobmanager}{major} ) {
+            $xml_ref->{jobmanager}{major} =
+                get_entry( 'Job Major Number',
+                $xml_ref->{jobmanager}{major} );
+        }
+        if ( $xml_ref->{jobmanager}{minor} ) {
+            $xml_ref->{jobmanager}{minor} =
+                get_entry( 'Job Minor Number',
+                $xml_ref->{jobmanager}{minor} );
+        }
     }
-    
-    # Adding
-    if($add){ 
-        $entryname = getEntry("Site Entry Name", $add);
-        if( -e "$dotswift/sites/$entryname/sites.xml") {
-            die "Entry file for $entryname already exists. Use -modify to change settings\n";
-        }
-	create_directory("$dotswift/sites/$entryname");
-        if(-e "$template_directory/$add/tc.data") { $tcfile = "$template_directory/$add/tc.data"; } 
-        elsif (-e "$dotswift/sites/$add/tc.data") { $tcfile = "$dotswift/sites/$add/tc.data"; }
-	copy("$tcfile", "$dotswift/sites/$entryname") || die "Unable to copy $tcfile to $dotswift/sites/$entryname\n";
 
-        if($entryname ne $add) {
-            update_tc_hostname("$dotswift/sites/$entryname/tc.data", $entryname);
+    # Execution
+    if ( $xml_ref->{execution} ) {
+        if ( $xml_ref->{execution}{provider} ) {
+            $xml_ref->{execution}{provider} = get_entry(
+                'Execution Provider',
+                $xml_ref->{execution}{provider},
+                @validproviders
+            );
         }
+        if ( $xml_ref->{execution}{jobmanager} ) {
+            $xml_ref->{execution}{jobmanager} =
+                get_entry( 'Execution Job Manager',
+                $xml_ref->{execution}{jobmanager} );
+        }
+        if ( $xml_ref->{execution}{url} ) {
+            $xml_ref->{execution}{url} =
+                get_entry( 'Execution URL', $xml_ref->{execution}{url} );
+        }
 
     }
 
-    $xml_data->{handle} = $entryname;
-    if(!-d "$dotswift/sites/$entryname") {
-        create_directory("$dotswift/sites/$entryname");
+    # Filesystem
+    if ( $xml_ref->{filesystem} ) {
+        if ( $xml_ref->{filesystem}{provider} ) {
+            $xml_ref->{filesystem}{provider} = get_entry(
+                'Filesystem Provider',
+                $xml_ref->{filesystem}{provider},
+                @validproviders
+            );
+        }
+        if ( $xml_ref->{filesystem}{url} ) {
+            $xml_ref->{filesystem}{url} =
+                get_entry( 'Filesystem URL', $xml_ref->{filesystem}{url} );
+        }
     }
-    $filename = "$dotswift/sites/$entryname/sites.xml";    
 
-    # Replace values if requested by user
-    $xml_data->{workdirectory}[0] =~ s/\$HOME/$ENV{'HOME'}/;
-    if ( $xml_data->{gridftp} ) { $xml_data->{gridftp}{url} = getEntry( "GridFTP URL", $xml_data->{gridftp}{url} ); }
-    if ( $xml_data->{workdirectory} ) { $xml_data->{workdirectory} = [ getEntry( "Work Directory", $xml_data->{workdirectory}[0] ) ]; }
-    if ( $xml_data->{jobmanager} ) {
-        if ( $xml_data->{jobmanager}{universe} ) { $xml_data->{jobmanager}{universe} = getEntry( "Job Universe", $xml_data->{jobmanager}{universe} ); }
-        if ( $xml_data->{jobmanager}{url} ) { $xml_data->{jobmanager}{url} = getEntry( "Job Manager URL", $xml_data->{jobmanager}{url} ); }
-        if ( $xml_data->{jobmanager}{major} ) { $xml_data->{jobmanager}{major} = getEntry( "Job Major Number", $xml_data->{jobmanager}{major} ); }
-        if ( $xml_data->{jobmanager}{minor} ) { $xml_data->{jobmanager}{minor} = getEntry( "Job Minor Number", $xml_data->{jobmanager}{minor} ); }
+    # Profiles
+    foreach my $profile ( @{ $xml_ref->{profile} } ) {
+        $profile->{content} =
+            get_entry( $profile->{key}, $profile->{content} );
     }
-    if ( $xml_data->{execution} ) {
-        if ( $xml_data->{execution}{provider} ) { $xml_data->{execution}{provider} = getEntry( "Execution Provider", $xml_data->{execution}{provider}, @validproviders); }
-        if ( $xml_data->{execution}{jobmanager} ) { $xml_data->{execution}{jobmanager} = getEntry( "Execution Job Manager", $xml_data->{execution}{jobmanager} ); }
-        if ( $xml_data->{execution}{url} ) { 
-            my $previous_site = $xml_data->{execution}{url};
-            $xml_data->{execution}{url} = getEntry( "Execution URL", $xml_data->{execution}{url} );
-	    update_tc_hostname("$tcfile", $xml_data->{execution}{url});
-       }
-    }
-    if ( $xml_data->{filesystem} ) {
-        if ( $xml_data->{filesystem}{provider} ) { $xml_data->{filesystem}{provider} = getEntry( "Filesystem Provider", $xml_data->{filesystem}{provider}, @validproviders); }
-        if ( $xml_data->{filesystem}{url} ) { $xml_data->{filesystem}{url} = getEntry( "Filesystem URL", $xml_data->{filesystem}{url} ); }
-    }
-    if ( $xml_data->{execution}{provider} eq "ssh") {
-	add_ssh_auth($entryname, $xml_data->{execution}{url});
-    } 
 
-    write_file( $filename, $xml->XMLout( $xml_data, RootName => 'pool', SuppressEmpty => 1 ) );
+    return $xml_ref;
 }
 
 # Write a file given variable and filename
 sub write_file {
     my ( $filename, @data ) = @_;
-    open( TEMPFILESTREAM, ">$filename" ) or die("Unable to open $filename!\n");
+    open( TEMPFILESTREAM, ">$filename" )
+        or die("Unable to open $filename!\n");
     print TEMPFILESTREAM @data;
     close(TEMPFILESTREAM);
 }
 
 # Print all files in a directory
 sub print_directory {
-    my ($template_directory) = @_;
-    chdir($template_directory) || die "Unable to change directories to $template_directory\n";
+    my ($directory) = @_;
+    chdir($directory)
+        || die "Unable to change directories to $directory\n";
     my @files = <*>;
-    foreach $file(@files)
-    {
-	(my $basename, my $ext) = split(/\./, $file);
-	my @path = split( '/', $basename);
-	print "$basename\n";
-    }  
+    foreach $file (@files) {
+        ( my $basename, my $ext ) = split( /\./, $file );
+        my @path = split( '/', $basename );
+        print "$basename\n";
+    }
 }
 
 # If a template is specified, find the correct one and modify as needed
-if ($add) {
-    my $data = 0;
-    $data = update_xml_entry("$template_directory/$add/sites.xml");
-    if ( $data == 0 ) { $data = update_xml_entry("$dotswift/sites/$add/sites.xml"); }
-    if ( $data == 0 ) { die "Unable to find template for $add\n"; }
+if ($option_add) {
+
+    # Update XML info
+    my $from_directory   = "$template_directory/$option_add";
+    my $sites_input_file = "$from_directory/sites.xml";
+    if ( !-e "$sites_input_file" ) {
+        $from_directory   = "$dotswift_directory/sites/$option_add";
+        $sites_input_file = "$from_directory/sites.xml";
+        if ( !-e "$sites_input_file" ) {
+            die "Unable to find $sites_input_file\n";
+        }
+    }
+    my $xml_ref          = update_xml("$sites_input_file");
+    my $new_sitename     = $xml_ref->{handle};
+    my $output_directory = "$dotswift_directory/sites/$new_sitename";
+    if ( -d "$output_directory" ) {
+        die "Entry for $new_sitename already exists\n";
+    }
+
+    # Update and copy files to reflect input
+    my @files_to_copy = <$from_directory/*>;
+    create_directory("$output_directory");
+    foreach $file_to_copy (@files_to_copy) {
+        copy( $file_to_copy, "$output_directory" )
+            || die "Unable to copy to $file to $output_directory\n";
+    }
+    my $xml_out_ref = $xml->XMLout(
+        $xml_ref,
+        RootName      => 'pool',
+        SuppressEmpty => 1,
+    );
+    write_file( "$output_directory/sites.xml", $xml_out_ref );
+
+    if ( $option_add ne $new_sitename ) {
+        my $tc_filename = "$output_directory/tc.data";
+        update_tc_hostname( "$tc_filename", $new_sitename );
+    }
+
+    # Handle SSH
+    if ( $xml_ref->{execution}{provider} eq 'ssh' ) {
+        add_ssh( $new_sitename, $xml_ref->{execution}{url} );
+    }
 }
 
+# Describe a site
+if ($option_describe) {
+    my $site_file = "$dotswift_directory/sites/$option_describe/sites.xml";
+    if ( !-e $site_file ) {
+        die "Unable to find $site_file\n";
+    }
+    system("cat $site_file");
+}
+
 # Remove an entry
-if ($remove) {
+if ($option_remove) {
 
-      if(!-d "$dotswift/sites/$remove") {
-          "Unable to find site entry for $remove\n";
-      }
+    if ( !-d "$dotswift_directory/sites/$option_remove" ) {
+        "Unable to find site entry for $option_remove\n";
+    }
 
-      rmtree("$dotswift/sites/$remove") || die "Unable to remove directory $dotswift/sites/$remove\n";
+    rmtree("$dotswift_directory/sites/$option_remove")
+        || die 'Unable to remove directory '
+        . "$dotswift_directory/sites/$option_remove\n";
 }
 
 # List all available templates
-if ($templates) {
+if ($option_templates) {
     print_directory($template_directory);
 }
 
 # List all user-added sites
-if($sites) {
-    print_directory("$dotswift/sites");
+if ($option_sites) {
+    print_directory("$dotswift_directory/sites");
 }
 
 # Modify a site entry
-if ($modify) {
-
-    if(!-e "$dotswift/sites/$modify/sites.xml") {
-        die "Unable to find entry for $modify\n";
+if ($option_modify) {
+    my $output_directory = "$dotswift_directory/sites/$option_modify";
+    my $sites_file       = "$output_directory/sites.xml";
+    if ( !-e "$sites_file" ) {
+        die "Unable to find configuration for $option_modify\n";
     }
 
-    my $data = update_xml_entry( "$dotswift/sites/$modify/sites.xml" );
+    my $xml_ref      = update_xml("$sites_file");
+    my $new_sitename = $xml_ref->{handle};
 
-}
+    create_directory($output_directory);
+    my $xml_out_ref = $xml->XMLout(
+        $xml_ref,
+        RootName      => 'pool',
+        SuppressEmpty => 1,
+    );
+    write_file( "$output_directory/sites.xml", $xml_out_ref );
 
-# Add or modify a TC entry
-if ($name) {
-    foreach $line (@tcdata) {
-
-        # Ignore comments
-        if ( substr( $line, 0, 1 ) eq '#' ) {
-            next;
+    # If the sitename has changed, move files
+    if ( $new_sitename ne $option_modify ) {
+        $output_directory = "$dotswift_directory/sites/$new_sitename";
+        if ( -d "$output_directory" ) {
+            die "Directory for $new_sitename already exists\n";
         }
-        ( $tmphost, $tmpname, @junk ) = split( /\s+/, $line );
-
-        # Replace old entry with new entry
-        if ( $name eq $tmpname && $host eq $tmphost ) {
-            $isfound = 1;
-            $line    = "$host\t$name\t$path\t$status\t$platform\t$profile\n";
-        }
+        move( "$dotswift_directory/sites/$option_modify",
+            "$output_directory" )
+            || die "Unable to rename $dotswift_directory/sites/$option_modify"
+            . " to $output_directory";
+        my $tc_filename = "$output_directory/tc.data";
+        update_tc_hostname( "$tc_filename", $new_sitename );
     }
 
-    # Add new entry
-    if ( !$isfound ) {
-        push( @tcdata, "$host\t$name\t$path\t$status\t$platform\t$profile\n" );
+    if ( $xml_ref->{execution}{provider} eq 'ssh' ) {
+        add_ssh( $xml_ref->{handle}, $xml_ref->{execution}{url} );
     }
-
-    # Write to tc.data
-    write_file( $tcfile, @tcdata );
 }
 
 __END__

Modified: usertools/swift/swiftconfig/bin/swiftrun
===================================================================
--- usertools/swift/swiftconfig/bin/swiftrun	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/bin/swiftrun	2010-07-30 09:43:43 UTC (rev 3491)
@@ -74,7 +74,7 @@
 
 GetOptions(
 	'site=s'     => \$site,
-        'script=s'   => \$script,
+     'script=s'   => \$script,
 );
 
 # Verify user-created profile info exists

Added: usertools/swift/swiftconfig/etc/sites/localhost/sites.xml
===================================================================
--- usertools/swift/swiftconfig/etc/sites/localhost/sites.xml	                        (rev 0)
+++ usertools/swift/swiftconfig/etc/sites/localhost/sites.xml	2010-07-30 09:43:43 UTC (rev 3491)
@@ -0,0 +1,6 @@
+<pool handle="localhost">
+  <execution provider="local" />
+  <gridftp url="local://localhost" />
+  <profile key="jobThrottle" namespace="karajan">0</profile>
+  <workdirectory>$HOME/swiftwork</workdirectory>
+</pool>

Added: usertools/swift/swiftconfig/etc/sites/localhost/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/localhost/tc.data	                        (rev 0)
+++ usertools/swift/swiftconfig/etc/sites/localhost/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -0,0 +1,8 @@
+# sitename  transformation  path   INSTALLED  platform  profiles
+localhost	echo	/bin/echo	INSTALLED	INTEL32::LINUX	null
+localhost	cat	/bin/cat	INSTALLED	INTEL32::LINUX	null
+localhost	ls	/bin/ls	INSTALLED	INTEL32::LINUX	null
+localhost	grep	/bin/grep	INSTALLED	INTEL32::LINUX	null
+localhost	sort	/bin/sort	INSTALLED	INTEL32::LINUX	null
+localhost	paste	/bin/paste	INSTALLED	INTEL32::LINUX	null
+localhost	tr	/usr/bin/tr	INSTALLED	INTEL32::LINUX	null

Modified: usertools/swift/swiftconfig/etc/sites/pads-local-pbs/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/pads-local-pbs/tc.data	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/pads-local-pbs/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -9,9 +9,9 @@
 #there must be no trailing whitespace at the end of each line.
 #
 # sitename  transformation  path   INSTALLED  platform  profiles
-localhost 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
-localhost 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
-localhost 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
-localhost 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
-localhost 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
-localhost 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
+pads-local-pbs 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null

Modified: usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/sites.xml
===================================================================
--- usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/sites.xml	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/sites.xml	2010-07-30 09:43:43 UTC (rev 3491)
@@ -1,13 +1,13 @@
-  <pool handle="pads-local-pbs-coasters">
-    <filesystem provider="local" url="none" />
-    <execution provider="coaster" url="none" jobmanager="local:pbs" />
-    <workdirectory>$HOME/swiftwork</workdirectory>
-    <profile namespace="globus" key="maxtime">3000</profile>
-    <profile namespace="globus" key="workersPerNode">8</profile>
-    <profile namespace="globus" key="slots">1</profile>
-    <profile namespace="globus" key="nodeGranularity">1</profile>
-    <profile namespace="globus" key="maxNodes">10</profile>
-    <profile namespace="globus" key="queue">short</profile>
-    <profile namespace="karajan" key="jobThrottle">0.5</profile>
-    <profile namespace="karajan" key="initialScore">10000</profile>
-  </pool>
+<pool handle="pads-local-pbs-coasters">
+   <filesystem provider="local" url="none" />
+   <execution provider="coaster" url="none" jobmanager="local:pbs" />
+   <workdirectory>$HOME/swiftwork</workdirectory>
+   <profile namespace="globus" key="maxtime">3000</profile>
+   <profile namespace="globus" key="workersPerNode">8</profile>
+   <profile namespace="globus" key="slots">1</profile>
+   <profile namespace="globus" key="nodeGranularity">1</profile>
+   <profile namespace="globus" key="maxNodes">10</profile>
+   <profile namespace="globus" key="queue">short</profile>
+   <profile namespace="karajan" key="jobThrottle">0.5</profile>
+   <profile namespace="karajan" key="initialScore">10000</profile>
+</pool>

Modified: usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/tc.data	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/pads-local-pbs-coasters/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -9,9 +9,9 @@
 #there must be no trailing whitespace at the end of each line.
 #
 # sitename  transformation  path   INSTALLED  platform  profiles
-localhost 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
-localhost 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
-localhost 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
-localhost 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
-localhost 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
-localhost 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs-coasters 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs-coasters 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs-coasters 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
+pads-local-pbs-coasters 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs-coasters 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
+pads-local-pbs-coasters 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null

Modified: usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/sites.xml
===================================================================
--- usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/sites.xml	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/sites.xml	2010-07-30 09:43:43 UTC (rev 3491)
@@ -1,4 +1,4 @@
-  <pool handle="pads-pbs-coasters-ssh">
+  <pool handle="pads-remote-pbs-coasters-ssh">
    <execution provider="coaster" url="login1.pads.ci.uchicago.edu" jobmanager="ssh:pbs" />
    <profile namespace="globus" key="maxtime">3000</profile>
    <profile namespace="globus" key="workersPerNode">8</profile>

Modified: usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/tc.data	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/pads-remote-pbs-coasters-ssh/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -9,9 +9,9 @@
 #there must be no trailing whitespace at the end of each line.
 #
 # sitename  transformation  path   INSTALLED  platform  profiles
-localhost 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
-localhost 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
-localhost 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
-localhost 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
-localhost 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
-localhost 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null
+pads-remote-pbs-coasters 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
+pads-remote-pbs-coasters 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
+pads-remote-pbs-coasters 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
+pads-remote-pbs-coasters 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
+pads-remote-pbs-coasters 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
+pads-remote-pbs-coasters 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null

Modified: usertools/swift/swiftconfig/etc/sites/pads-remote-ssh/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/pads-remote-ssh/tc.data	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/pads-remote-ssh/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -9,9 +9,9 @@
 #there must be no trailing whitespace at the end of each line.
 #
 # sitename  transformation  path   INSTALLED  platform  profiles
-localhost 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
-localhost 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
-localhost 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
-localhost 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
-localhost 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
-localhost 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null
+pads-remote-ssh 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
+pads-remote-ssh 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
+pads-remote-ssh 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
+pads-remote-ssh 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
+pads-remote-ssh 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
+pads-remote-ssh 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null

Modified: usertools/swift/swiftconfig/etc/sites/teraport-local-pbs/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/teraport-local-pbs/tc.data	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/teraport-local-pbs/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -9,9 +9,9 @@
 #there must be no trailing whitespace at the end of each line.
 #
 # sitename  transformation  path   INSTALLED  platform  profiles
-none	echo	/bin/echo	INSTALLED	INTEL32::LINUX	null
-none	cat	/bin/cat	INSTALLED	INTEL32::LINUX	null
-none	ls	/bin/ls	INSTALLED	INTEL32::LINUX	null
-none	grep	/bin/grep	INSTALLED	INTEL32::LINUX	null
-none	sort	/bin/sort	INSTALLED	INTEL32::LINUX	null
-none	paste	/bin/paste	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs	echo	/bin/echo	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs	cat	/bin/cat	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs	ls	/bin/ls	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs	grep	/bin/grep	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs	sort	/bin/sort	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs	paste	/bin/paste	INSTALLED	INTEL32::LINUX	null

Modified: usertools/swift/swiftconfig/etc/sites/teraport-local-pbs-coasters/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/teraport-local-pbs-coasters/tc.data	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/teraport-local-pbs-coasters/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -9,9 +9,9 @@
 #there must be no trailing whitespace at the end of each line.
 #
 # sitename  transformation  path   INSTALLED  platform  profiles
-localhost 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
-localhost 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
-localhost 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
-localhost 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
-localhost 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
-localhost 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs-coasters 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs-coasters 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs-coasters 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs-coasters 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs-coasters 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
+teraport-local-pbs-coasters 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null

Modified: usertools/swift/swiftconfig/etc/sites/teraport-remote-ssh/tc.data
===================================================================
--- usertools/swift/swiftconfig/etc/sites/teraport-remote-ssh/tc.data	2010-07-28 22:44:31 UTC (rev 3490)
+++ usertools/swift/swiftconfig/etc/sites/teraport-remote-ssh/tc.data	2010-07-30 09:43:43 UTC (rev 3491)
@@ -9,9 +9,9 @@
 #there must be no trailing whitespace at the end of each line.
 #
 # sitename  transformation  path   INSTALLED  platform  profiles
-localhost 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
-localhost 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
-localhost 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
-localhost 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
-localhost 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
-localhost 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null
+teraport-remote-ssh 	echo 		/bin/echo	INSTALLED	INTEL32::LINUX	null
+teraport-remote-ssh 	cat 		/bin/cat	INSTALLED	INTEL32::LINUX	null
+teraport-remote-ssh 	ls 		/bin/ls		INSTALLED	INTEL32::LINUX	null
+teraport-remote-ssh 	grep 		/bin/grep	INSTALLED	INTEL32::LINUX	null
+teraport-remote-ssh 	sort 		/bin/sort	INSTALLED	INTEL32::LINUX	null
+teraport-remote-ssh 	paste 		/bin/paste	INSTALLED	INTEL32::LINUX	null




More information about the Swift-commit mailing list