[Swift-commit] r3543 - in usertools/swift/swiftconfig: bin etc lib/perl

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Aug 16 12:40:59 CDT 2010


Author: davidk
Date: 2010-08-16 12:40:59 -0500 (Mon, 16 Aug 2010)
New Revision: 3543

Modified:
   usertools/swift/swiftconfig/bin/swiftconfig
   usertools/swift/swiftconfig/bin/swiftrun
   usertools/swift/swiftconfig/etc/TODO
   usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm
Log:
Import of existing, standard sites.xml files into swiftconfig format


Modified: usertools/swift/swiftconfig/bin/swiftconfig
===================================================================
--- usertools/swift/swiftconfig/bin/swiftconfig	2010-08-16 15:57:42 UTC (rev 3542)
+++ usertools/swift/swiftconfig/bin/swiftconfig	2010-08-16 17:40:59 UTC (rev 3543)
@@ -13,6 +13,7 @@
 use Getopt::Long;
 use XML::Simple;
 use File::Which qw(which where);
+use Data::Dumper;
 
 # Variables used for sites.xml
 my $option_templates    = q{};            # List all templates
@@ -24,6 +25,7 @@
 my $option_template     = q{};            # Create config from template specified
 my $option_copy         = q{};            # Copy an existing configuration
 my $option_applications = q{};            # Edit applications
+my $option_import       = q{};            # Import existing configuration
 
 # Assign variables from command line options
 GetOptions(
@@ -37,7 +39,8 @@
     'edit=s'                => \$option_edit,
     'copy=s'                => \$option_copy,
     'apps|applications'     => \$option_applications,
-    'help|man'                  => sub { pod2usage(-verbose => 2); },
+    'import=s'              => \$option_import,
+    'help|man'              => sub { pod2usage(-verbose => 2); },
 );
 
 # Prepare data
@@ -85,10 +88,6 @@
     write_file( "$output_directory/sites.xml", $xml_out_ref );
 
     update_site_applications($new_sitename);
-    #if ( $option_template 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' ) {
@@ -111,17 +110,6 @@
     if ( !-d "$dotswift_directory/sites/$option_remove" ) {
         die "Unable to find configuration named $option_remove\n";
     }
-    
-    # Remove SSH entry if needed
-    #my $xml_filename = "$dotswift_directory/sites/$option_remove/sites.xml";
-    #my $xml_ref = $xml->XMLin(
-    #    $xml_filename,
-    #    ForceArray => [qw(workdirectory profile)],
-    #    KeyAttr    => [],
-    #);
-    #if($xml_ref->{execution}{provider} eq "ssh") {
-    #    remove_ssh($xml_ref->{execution}{url});
-    #}
 
     # Remove directory           
     rmtree("$dotswift_directory/sites/$option_remove")
@@ -277,9 +265,41 @@
            elsif(lc($edit_or_add) eq 'e') {
                 edit_application("$dotswift_directory/apps/$application_set.apps");
            }
-       }
+     }
 }
 
+# Import existing configurations
+if($option_import) {
+    if(! -e $option_import) {
+        die "Unable to find file to import: $option_import\n";
+    }
+    
+    my $xml_ref = $xml->XMLin(
+        $option_import,
+        ForceArray => [qw(workdirectory profile pool)],
+        KeyAttr    => "pool",
+    );
+    
+    foreach my $pool ( @{$xml_ref->{pool}} ) {
+        if(-d "$dotswift_directory/sites/$pool->{handle}") {
+            print "Configuration for $pool->{handle} already exists. Skipping\n";
+        }
+        else {
+            create_directory("$dotswift_directory/sites/$pool->{handle}");
+            my $xml_out_ref = $xml->XMLout(
+                $pool,
+                RootName      => 'pool',
+                SuppressEmpty => 1,
+            );
+            write_file("$dotswift_directory/sites/$pool->{handle}/sites.xml", 
+                        $xml_out_ref );
+            update_site_applications($pool->{handle});
+            print "Successfully imported $pool->{handle}\n\n";
+        }
+    }
+}
+
+
 __END__
 
 =head1 NAME

Modified: usertools/swift/swiftconfig/bin/swiftrun
===================================================================
--- usertools/swift/swiftconfig/bin/swiftrun	2010-08-16 15:57:42 UTC (rev 3542)
+++ usertools/swift/swiftconfig/bin/swiftrun	2010-08-16 17:40:59 UTC (rev 3543)
@@ -173,6 +173,7 @@
 }
 
 # Execute
+print "Executing: $system_command\n";
 system($system_command);
 
 __END__

Modified: usertools/swift/swiftconfig/etc/TODO
===================================================================
--- usertools/swift/swiftconfig/etc/TODO	2010-08-16 15:57:42 UTC (rev 3542)
+++ usertools/swift/swiftconfig/etc/TODO	2010-08-16 17:40:59 UTC (rev 3543)
@@ -1,14 +1,9 @@
-TC editing
-In the short term, re-add ability to edit TC file with an interactive editor
-Longer term, eliminate TC and search PATH instead
-
 Running and testing on more setups, OSG, teragrid, others
 
 Job tagging with search capabilities
 
-Ability to create groups of related sites for runs, ability to run on all 
-sites (-site all, -site mygroup, etc)
+Ability to group groups of sites (other than 'all')
 
 Have swiftrun be flexible enough to work for new users, as well as advanced users 
 
-Add -help or similar
+swiftconfig -import to allow integration with existing configurations

Modified: usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm
===================================================================
--- usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm	2010-08-16 15:57:42 UTC (rev 3542)
+++ usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm	2010-08-16 17:40:59 UTC (rev 3543)
@@ -579,7 +579,7 @@
     }
     print "\n";
     
-    print "Enter applications sets for $site: ";
+    print "Enter application sets for $site: ";
     $apps = <STDIN>;
     chomp($apps);
     my @all_list = split(/ /, $apps);




More information about the Swift-commit mailing list