[Swift-commit] r3535 - usertools/swift/swiftconfig/bin
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Sat Aug 14 17:45:00 CDT 2010
Author: davidk
Date: 2010-08-14 17:45:00 -0500 (Sat, 14 Aug 2010)
New Revision: 3535
Modified:
usertools/swift/swiftconfig/bin/swiftconfig
Log:
Better transitioning between execution providers
Modified: usertools/swift/swiftconfig/bin/swiftconfig
===================================================================
--- usertools/swift/swiftconfig/bin/swiftconfig 2010-08-14 01:22:46 UTC (rev 3534)
+++ usertools/swift/swiftconfig/bin/swiftconfig 2010-08-14 22:45:00 UTC (rev 3535)
@@ -84,18 +84,23 @@
return $entry_value;
}
- if(!@allowable_values) {
+ if(!@allowable_values) {
print "$entry_description [$entry_value]: ";
}
else {
print "$entry_description [";
+ my $counter=0;
foreach my $allowable(@allowable_values) {
+ if($counter != 0) {
+ print " ";
+ }
if($allowable eq $entry_value) {
- print "*$allowable ";
+ print "*$allowable";
}
else {
- print "$allowable ";
+ print "$allowable";
}
+ $counter++;
}
print "]: ";
}
@@ -283,6 +288,53 @@
$xml_ref->{handle} = get_entry( 'Site Entry Name', $xml_ref->{handle}, $option_default);
}
+ # Execution
+ my $initial_exprovider = $xml_ref->{execution}{provider};
+ $xml_ref->{execution}{provider} = get_entry(
+ 'Execution Provider',
+ $xml_ref->{execution}{provider},
+ $option_default,
+ @execution_providers,
+ );
+ my $current_exprovider = $xml_ref->{execution}{provider};
+
+ # Handle changes in execution provider
+ if( $initial_exprovider ne $current_exprovider ) {
+ # Add SSH fields
+ if( $current_exprovider eq 'ssh' ) {
+ if( !$xml_ref->{execution}{url} ) {
+ $xml_ref->{execution}{url} = 'unknown';
+ }
+ }
+ # Add coaster fields
+ if( $current_exprovider eq 'coaster' ) {
+ if( !$xml_ref->{execution}{jobmanager} ) {
+ $xml_ref->{execution}{jobmanager} = 'unknown';
+ }
+ if( !$xml_ref->{execution}{url} ){
+ $xml_ref->{execution}{url} = 'unknown';
+ }
+ }
+ }
+
+ # Job manager
+ if ( $xml_ref->{execution}{jobmanager}) {
+ $xml_ref->{execution}{jobmanager} =
+ get_entry( 'Execution Job Manager',
+ $xml_ref->{execution}{jobmanager},
+ $option_default
+ );
+ }
+
+ # Execution URL
+ if ( $xml_ref->{execution}{url} ) {
+ $xml_ref->{execution}{url} =
+ get_entry( 'Execution URL',
+ $xml_ref->{execution}{url},
+ $option_default
+ );
+ }
+
# Grid FTP
if ( $xml_ref->{gridftp} ) {
$xml_ref->{gridftp}{url} =
@@ -318,28 +370,6 @@
}
}
- # Execution
- if ( $xml_ref->{execution} ) {
- if ( $xml_ref->{execution}{provider} ) {
- $xml_ref->{execution}{provider} = get_entry(
- 'Execution Provider',
- $xml_ref->{execution}{provider},
- $option_default,
- @execution_providers,
- );
- }
- if ( $xml_ref->{execution}{jobmanager} ) {
- $xml_ref->{execution}{jobmanager} =
- get_entry( 'Execution Job Manager',
- $xml_ref->{execution}{jobmanager},
- $option_default);
- }
- if ( $xml_ref->{execution}{url} ) {
- $xml_ref->{execution}{url} =
- get_entry( 'Execution URL', $xml_ref->{execution}{url}, $option_default);
- }
- }
-
# Filesystem
if ( $xml_ref->{filesystem} ) {
if ( $xml_ref->{filesystem}{provider} ) {
@@ -432,13 +462,18 @@
if ($option_describe) {
my $site_file = "$dotswift_directory/sites/$option_describe/sites.xml";
if ( !-e $site_file ) {
- die "Unable to find $site_file\n";
+ die "Unable to locate configuration for $option_describe\n";
}
system("cat $site_file");
}
# Remove an entry
if ($option_remove) {
+
+ if ( !-d "$dotswift_directory/sites/$option_remove" ) {
+ die "Unable to find configuration named $option_remove\n";
+ }
+
my $xml_filename = "$dotswift_directory/sites/$option_remove/sites.xml";
my $xml_ref = $xml->XMLin(
$xml_filename,
@@ -447,14 +482,11 @@
);
# Remove SSH entry if needed
- if($xml_ref->{execution}{provider} eq "ssh") {
- remove_ssh($xml_ref->{execution}{url});
- }
+ #if($xml_ref->{execution}{provider} eq "ssh") {
+ # remove_ssh($xml_ref->{execution}{url});
+ #}
# Remove directory
- if ( !-d "$dotswift_directory/sites/$option_remove" ) {
- die "Unable to find site entry for $option_remove\n";
- }
rmtree("$dotswift_directory/sites/$option_remove")
|| die 'Unable to remove directory '
. "$dotswift_directory/sites/$option_remove\n";
@@ -486,12 +518,9 @@
ForceArray => [qw(workdirectory profile)],
KeyAttr => [],
);
+ $xml_ref = update_xml("$sites_file", 1);
- my $initial_exurl = $xml_ref->{execution}{url};
- $xml_ref = update_xml("$sites_file", 1);
- my $new_exurl = $xml_ref->{execution}{url};
- #my $new_sitename = $xml_ref->{handle};
-
+ # Save
my $xml_out_ref = $xml->XMLout(
$xml_ref,
RootName => 'pool',
@@ -501,9 +530,6 @@
# Add/modify/remove ssh entries as needed
if ( $xml_ref->{execution}{provider} eq 'ssh' ) {
- if ( $initial_exurl && $initial_exurl ne $new_exurl ) {
- remove_ssh( $initial_exurl );
- }
add_ssh( $xml_ref->{handle}, $xml_ref->{execution}{url} );
}
}
More information about the Swift-commit
mailing list