[Swift-commit] r3529 - usertools/swift/swiftconfig/bin
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Fri Aug 13 00:12:44 CDT 2010
Author: davidk
Date: 2010-08-13 00:12:44 -0500 (Fri, 13 Aug 2010)
New Revision: 3529
Modified:
usertools/swift/swiftconfig/bin/swiftconfig
Log:
-default and -full modes for adding in swiftconfig
Modified: usertools/swift/swiftconfig/bin/swiftconfig
===================================================================
--- usertools/swift/swiftconfig/bin/swiftconfig 2010-08-13 04:13:38 UTC (rev 3528)
+++ usertools/swift/swiftconfig/bin/swiftconfig 2010-08-13 05:12:44 UTC (rev 3529)
@@ -52,18 +52,22 @@
my $option_add = q{}; # Add entry
my $option_sites = q{}; # List all usable sites
my $option_describe = q{}; # Print raw XML configuration
+my $option_default = q{}; # When adding a site, use all defaults
+
my @execution_providers =
( "gt4", "local", "pbs", "condor", "ssh", "coaster", );
# Assign variables from command line options
GetOptions(
- '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,
+ '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,
+ 'default|defaults' => \$option_default,
+ 'full' => sub { $option_default = 0; },
);
# Create a new directory if it does not exist
@@ -77,8 +81,12 @@
# Process keyboard input
sub get_entry {
- my ( $entry_description, $entry_value, @allowable_values, ) = @_;
+ my ( $entry_description, $entry_value, $use_default, @allowable_values, ) = @_;
+ if($use_default) {
+ return $entry_value;
+ }
+
print "$entry_description [$entry_value]: ";
my $new_value = <STDIN>;
chomp($new_value);
@@ -148,14 +156,14 @@
if (/username/i && /^$ssh_url/i) {
( my $setting, $ssh_username, ) = split( '=', $_ );
chomp($ssh_username);
- $ssh_username = get_entry( 'Username', $ssh_username );
+ $ssh_username = get_entry( 'Username', $ssh_username, 0);
$_ = "$ssh_url.username=$ssh_username\n";
$found = 1;
}
if (/\.password/i && /^$ssh_url/i) {
( my $setting, $ssh_password, ) = split( '=', $_ );
chomp($ssh_password);
- $ssh_password = get_entry( 'Password', $ssh_password );
+ $ssh_password = get_entry( 'Password', $ssh_password, 0);
$_ = "$ssh_url.password=$ssh_password\n";
$found = 1;
}
@@ -164,8 +172,8 @@
# Add new entry if needed
if(!$found) {
$ssh_username = getlogin();
- $ssh_username = get_entry( 'Username', $ssh_username );
- $ssh_password = get_entry( 'Password', '');
+ $ssh_username = get_entry( 'Username', $ssh_username, 0 );
+ $ssh_password = get_entry( 'Password', '', 0);
# Password based authentication
push( @auth_data, "$ssh_url.type=password\n" );
@@ -254,40 +262,40 @@
);
# Handle
- $xml_ref->{handle} = get_entry( 'Site Entry Name', $xml_ref->{handle} );
+ $xml_ref->{handle} = get_entry( 'Site Entry Name', $xml_ref->{handle}, $option_default);
# Grid FTP
if ( $xml_ref->{gridftp} ) {
$xml_ref->{gridftp}{url} =
- get_entry( 'GridFTP URL', $xml_ref->{gridftp}{url} );
+ get_entry( 'GridFTP URL', $xml_ref->{gridftp}{url}, $option_default);
}
# 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] ) ];
+ [ get_entry( 'Work Directory', $xml_ref->{workdirectory}[0], $option_default) ];
}
# Job manager
if ( $xml_ref->{jobmanager} ) {
if ( $xml_ref->{jobmanager}{universe} ) {
$xml_ref->{jobmanager}{universe} =
- get_entry( 'Job Universe', $xml_ref->{jobmanager}{universe} );
+ get_entry( 'Job Universe', $xml_ref->{jobmanager}{universe}, $option_default);
}
if ( $xml_ref->{jobmanager}{url} ) {
$xml_ref->{jobmanager}{url} =
- get_entry( 'Job Manager URL', $xml_ref->{jobmanager}{url} );
+ get_entry( 'Job Manager URL', $xml_ref->{jobmanager}{url}, $option_default);
}
if ( $xml_ref->{jobmanager}{major} ) {
$xml_ref->{jobmanager}{major} =
get_entry( 'Job Major Number',
- $xml_ref->{jobmanager}{major} );
+ $xml_ref->{jobmanager}{major}, $option_default);
}
if ( $xml_ref->{jobmanager}{minor} ) {
$xml_ref->{jobmanager}{minor} =
get_entry( 'Job Minor Number',
- $xml_ref->{jobmanager}{minor} );
+ $xml_ref->{jobmanager}{minor}, $option_default);
}
}
@@ -297,19 +305,20 @@
$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} );
+ $xml_ref->{execution}{jobmanager},
+ $option_default);
}
if ( $xml_ref->{execution}{url} ) {
$xml_ref->{execution}{url} =
- get_entry( 'Execution URL', $xml_ref->{execution}{url} );
+ get_entry( 'Execution URL', $xml_ref->{execution}{url}, $option_default);
}
-
}
# Filesystem
@@ -318,19 +327,20 @@
$xml_ref->{filesystem}{provider} = get_entry(
'Filesystem Provider',
$xml_ref->{filesystem}{provider},
+ $option_default,
@execution_providers,
);
}
if ( $xml_ref->{filesystem}{url} ) {
$xml_ref->{filesystem}{url} =
- get_entry( 'Filesystem URL', $xml_ref->{filesystem}{url} );
+ get_entry( 'Filesystem URL', $xml_ref->{filesystem}{url}, $option_default);
}
}
# Profiles
foreach my $profile ( @{ $xml_ref->{profile} } ) {
$profile->{content} =
- get_entry( $profile->{key}, $profile->{content} );
+ get_entry( $profile->{key}, $profile->{content}, $option_default);
}
return $xml_ref;
More information about the Swift-commit
mailing list