doesn't crash so badly when run right after yum install
[sfa.git] / geni-config-tty
index 2fc9896..8524170 100755 (executable)
@@ -16,7 +16,7 @@ import os
 import re
 import readline
 import traceback
-import distutils
+import distutils.file_util
 from optparse import OptionParser
 
 from geni.util.config import Config
@@ -24,7 +24,7 @@ from geni.util.hierarchy import *
 from geni.util.misc import *
 
 
-usual_variables = ["GENI_REGISTRY_ROOT_AUTH",
+all_variables   = ["GENI_REGISTRY_ROOT_AUTH",
                    "GENI_REGISTRY_LEVEL1_AUTH",
                    "GENI_REGISTRY_ENABLED",
                    "GENI_REGISTRY_HOST", 
@@ -41,6 +41,11 @@ usual_variables = ["GENI_REGISTRY_ROOT_AUTH",
                    "GENI_PLC_PORT",
                    "GENI_PLC_API_PATH"
                    ]
+usual_variables = ["GENI_REGISTRY_ROOT_AUTH",
+                   "GENI_REGISTRY_LEVEL1_AUTH",
+                   "GENI_PLC_USER",
+                   "GENI_PLC_PASSWORD",    
+                   ]
 
 
 mainloop_usage= """Available commands:
@@ -97,11 +102,12 @@ def save_config(changes, config_file):
     print 'updated config file',config_file
 
 def validate(changes):
-    defaults = get_defaults()
-    
+
     if not changes:
         return {}
 
+    defaults = get_defaults()
+    
     # GENI_INTERFACE_HRN is GENI_REGISTRY_LEVEL1_AUTH, if thats blank it
     # then defaults to GENI_REGISTRY_ROOT_AUTH 
     # GENI_REGISTRY_LEVEL1_AUTH, so if either of these are present we must 
@@ -162,7 +168,7 @@ def prompt_variable(variable, default_config):
             raise Exception ('BailOut')
         except KeyboardInterrupt:
             print "\n"
-            raise Excception ('BailOut')
+            raise Exception ('BailOut')
 
         if (answer == "") or (answer == default_value):
             return default_value
@@ -247,7 +253,7 @@ def setup_server_key(config_dict):
     hrn_leaf = get_leaf(hrn)
     if not hrn_leaf:
         hrn_leaf = hrn
-    new_server_key = os.sep.join([path, auth_path, hrn_leaf])
+    new_server_key = os.sep.join([path, auth_path, hrn_leaf]) + ".pkey"
     old_server_key = os.sep.join([path, key])
     old_server_cert = os.sep.join([path, cert])
 
@@ -257,8 +263,12 @@ def setup_server_key(config_dict):
             os.remove(fd)
 
     # create new server.key
-    distutils.file_util.copy_file(src=new_server_key, dst=old_server_key, verbose=1)
-    print "\t\t%(old_server_key)s\ncopied from\t%(new_server_key)s" % locals()
+    try:
+        distutils.file_util.copy_file(src=new_server_key, dst=old_server_key, verbose=1)
+        print "\t\t%(old_server_key)s\ncopied from\t%(new_server_key)s" % locals()
+    # this is expected when running geni-config-tty for the first time (before gimport.py)
+    except:
+        print "Could not create %(old_server_key)s - ignore if you haven't run gimport yet"%locals()