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

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Aug 16 14:45:14 CDT 2010


Author: davidk
Date: 2010-08-16 14:45:14 -0500 (Mon, 16 Aug 2010)
New Revision: 3546

Modified:
   usertools/swift/swiftconfig/bin/swiftconfig
   usertools/swift/swiftconfig/bin/swiftrun
   usertools/swift/swiftconfig/etc/TODO
   usertools/swift/swiftconfig/etc/apps/imagemagick.apps
   usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm
Log:
Importer to existing TC files


Modified: usertools/swift/swiftconfig/bin/swiftconfig
===================================================================
--- usertools/swift/swiftconfig/bin/swiftconfig	2010-08-16 18:49:25 UTC (rev 3545)
+++ usertools/swift/swiftconfig/bin/swiftconfig	2010-08-16 19:45:14 UTC (rev 3546)
@@ -131,7 +131,6 @@
         SuppressEmpty => 1,
     );
     write_file( "$output_directory/sites.xml", $xml_out_ref );
-
     update_site_applications($option_edit);
     
     # Add/modify/remove ssh entries as needed
@@ -249,32 +248,11 @@
 
 # Import existing configurations
 if($option_import) {
-    if(! -e $option_import) {
-        die "Unable to find file to import: $option_import\n";
+    if($option_import =~ m/\.xml/gi) {
+        import_xml($option_import);
     }
-    
-    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";
-        }
+    if($option_import =~ m/\.data/gi) {
+        import_tc($option_import);
     }
 }
 

Modified: usertools/swift/swiftconfig/bin/swiftrun
===================================================================
--- usertools/swift/swiftconfig/bin/swiftrun	2010-08-16 18:49:25 UTC (rev 3545)
+++ usertools/swift/swiftconfig/bin/swiftrun	2010-08-16 19:45:14 UTC (rev 3546)
@@ -83,7 +83,7 @@
             close(CURRENT_APP);
             $all_site = strip_directory($all_site);
             foreach(@current_app_data) {
-                s/\$HOST/$all_site/ig;
+                s/SWIFTCONFIGURATION/$all_site/ig;
             }
             open(RUNTC, ">>$run_directory/tc.data") || die "Unable to write to $run_directory/tc.data\n";
             print RUNTC @current_app_data;
@@ -127,7 +127,7 @@
             my @current_app_data = <CURRENT_APP>;
             close(CURRENT_APP);
             foreach(@current_app_data) {
-                s/\$HOST/$site/ig;
+                s/SWIFTCONFIGURATION/$site/ig;
             }
             open(RUNTC, ">>$run_directory/tc.data") || die "Unable to write to $run_directory/tc.data\n";
             print RUNTC @current_app_data;
@@ -173,7 +173,6 @@
 }
 
 # Execute
-print "Executing: $system_command\n";
 system($system_command);
 
 __END__

Modified: usertools/swift/swiftconfig/etc/TODO
===================================================================
--- usertools/swift/swiftconfig/etc/TODO	2010-08-16 18:49:25 UTC (rev 3545)
+++ usertools/swift/swiftconfig/etc/TODO	2010-08-16 19:45:14 UTC (rev 3546)
@@ -4,3 +4,4 @@
 Have swiftrun be flexible enough to work for new users, as well as advanced users 
 Site aliases
 Ability to "undo" edits
+Replace $HOST in app templates with something else

Modified: usertools/swift/swiftconfig/etc/apps/imagemagick.apps
===================================================================
--- usertools/swift/swiftconfig/etc/apps/imagemagick.apps	2010-08-16 18:49:25 UTC (rev 3545)
+++ usertools/swift/swiftconfig/etc/apps/imagemagick.apps	2010-08-16 19:45:14 UTC (rev 3546)
@@ -1,11 +1,11 @@
-$HOST	convert	/usr/bin/convert	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	mogrify	/usr/bin/mogrify	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	identify	/usr/bin/identify	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	composite	/usr/bin/composite	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	montage	/usr/bin/montage	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	compare	/usr/bin/compare	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	stream	/usr/bin/stream	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	display	/usr/bin/display	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	animate	/usr/bin/animate	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	import	/usr/bin/import	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
-$HOST	conjure	/usr/bin/conjure	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	convert	/usr/bin/convert	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	mogrify	/usr/bin/mogrify	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	identify	/usr/bin/identify	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	composite	/usr/bin/composite	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	montage	/usr/bin/montage	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	compare	/usr/bin/compare	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	stream	/usr/bin/stream	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	display	/usr/bin/display	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	animate	/usr/bin/animate	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	import	/usr/bin/import	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"
+SWIFTCONFIGURATION	conjure	/usr/bin/conjure	INSTALLED	INTEL32::LINUX	GLOBUS::maxwalltime="00:05:00"

Modified: usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm
===================================================================
--- usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm	2010-08-16 18:49:25 UTC (rev 3545)
+++ usertools/swift/swiftconfig/lib/perl/SwiftConfig.pm	2010-08-16 19:45:14 UTC (rev 3546)
@@ -20,7 +20,8 @@
 our @EXPORT = qw(create_directory get_entry add_ssh remove_ssh 
 update_tc_hostname update_xml write_file print_directory strip_directory
 copy_file cat_file add_application edit_application remove_application
-list_applications initialize_swiftconfig update_site_applications
+list_applications initialize_swiftconfig update_site_applications import_tc
+import_xml
 );
 our $VERSION = '0.01';
 
@@ -560,7 +561,6 @@
         my @apps_file_data = <APPLIST>;
         close(APPLIST);
         foreach my $current_app (@apps_file_data) {
-            print "Looking at: $current_app\n";
             if($apps) { 
                 $apps = "$apps $current_app";
             }
@@ -569,7 +569,6 @@
             }
        }       
     }
-    print "Apps: $apps\n";
     
     my @all_available_appsets = glob("$ENV{'HOME'}/.swift/apps/*.apps");
     print "Available application sets are: ";
@@ -580,7 +579,10 @@
     }
     print "\n";
     
-    $apps = get_entry("Application sets for $site", $apps, 0);
+    print "Application sets for $site: ";
+    $apps = <STDIN>;
+    chomp($apps);
+    
     my @all_list = split(/ /, $apps);
     open(APPFILE, ">$ENV{'HOME'}/.swift/sites/$site/apps")
         || die "Unable to open $ENV{'HOME'}/.swift/sites/$site/apps for writing!\n";
@@ -588,7 +590,59 @@
         print APPFILE "$_\n";
     }
     close(APPFILE);
+    print "Successfully saved application sets for $site\n\n";
 }
+
+sub import_xml {
+    my ($xml_filename) = @_;
+    if(! -e $xml_filename) {
+        die "Unable to find file to import: $xml_filename\n";
+    }
+    
+    my $xml_ref = $xml->XMLin(
+        $xml_filename,
+        ForceArray => [qw(workdirectory profile pool)],
+        KeyAttr    => "pool",
+    );
+    
+    foreach my $pool ( @{$xml_ref->{pool}} ) {
+        if(-d "$ENV{'HOME'}/.swift/sites/$pool->{handle}") {
+            print "Configuration for $pool->{handle} already exists. Skipping\n";
+        }
+        else {
+            create_directory("$ENV{'HOME'}/.swift/sites/$pool->{handle}");
+            my $xml_out_ref = $xml->XMLout(
+                $pool,
+                RootName      => 'pool',
+                SuppressEmpty => 1,
+            );
+            write_file("$ENV{'HOME'}/.swift/sites/$pool->{handle}/sites.xml", 
+                        $xml_out_ref );
+            update_site_applications($pool->{handle});
+        }
+    }
+}
+
+sub import_tc {
+    my ($tc_filename) = @_;
+    if(! -e $tc_filename) {
+        die "Unable to find file to import: $tc_filename\n";
+    }
+    open(TCFILE, $tc_filename) || die "Unable to open $tc_filename for reading\n";
+    my @tc_data = <TCFILE>;
+    close(TCFILE);
+    foreach(@tc_data) {
+        my ($site, $name, $path, $status, $platform, $profile) = split(/\s+/);
+        $site = "SWIFTCONFIGURATION";
+        $_ = "$site\t$name\t$path\t$status\t$platform\t$profile\n";
+   }
+   print "Enter name to call this application set: ";
+   my $set_name = <STDIN>;
+   chomp($set_name);
+   write_file("$ENV{'HOME'}/.swift/apps/$set_name.apps", @tc_data);
+   print "Successfully imported application set named $set_name\n";
+}
+
 1;
 __END__
 




More information about the Swift-commit mailing list